Index: composer.postload.js |
diff --git a/composer.postload.js b/composer.postload.js |
index e45eed440fbbbea70d746d9635e680894f922109..3c072fb90bd964cdc655f72bb9434b1a2f7309fe 100644 |
--- a/composer.postload.js |
+++ b/composer.postload.js |
@@ -64,6 +64,11 @@ function getFiltersForElement(element, callback) |
function getBlockableElementOrAncestor(element, callback) |
{ |
+ // If we're offering to block the iframe element given by window.frameElement |
+ // we must use the context of the parent frame. |
+ let document = element.ownerDocument; |
+ let HTMLElement = document.defaultView.HTMLElement; |
+ |
// We assume that the user doesn't want to block the whole page. |
// So we never consider the <html> or <body> element. |
while (element && element != document.documentElement && |
@@ -122,6 +127,8 @@ function getBlockableElementOrAncestor(element, callback) |
// Adds an overlay to an element in order to highlight it. |
function addElementOverlay(element) |
{ |
+ let document = element.ownerDocument; |
+ |
let position = "absolute"; |
let offsetX = window.scrollX; |
let offsetY = window.scrollY; |
@@ -421,8 +428,11 @@ function elementPicked(event) |
highlightElement(currentElement, "#fd1708", "#f6a1b5"); |
}); |
- event.preventDefault(); |
- event.stopPropagation(); |
+ if (event) |
+ { |
+ event.preventDefault(); |
+ event.stopPropagation(); |
+ } |
} |
function stopPickingElement() |
@@ -520,10 +530,23 @@ if (document instanceof HTMLDocument) |
break; |
case "composer.content.contextMenuClicked": |
let event = lastRightClickEvent; |
+ let target = event && event.target; |
+ |
+ // When the user attempts to block an element inside an iframe for which |
+ // our right click event listener was trashed the best we can do is to |
+ // offer to block the entire iframe. This of course only works if the |
+ // parent frame is considered to be of the same origin. |
+ // Note: Since Edge doesn't yet support per-frame messaging[1] we |
+ // can't use this workaround there yet. (The contextMenuClicked message |
+ // will be sent to all of the page's frames.) |
+ // [1] - https://developer.microsoft.com/en-us/microsoft-edge/platform/documentation/extensions/api-support/supported-apis/ |
+ if (!target && window.frameElement && typeof chrome != "undefined") |
kzar
2017/08/09 15:29:24
Note: This check `typeof chrome != "undefined"` is
kzar
2017/10/18 14:57:26
Done.
|
+ target = addElementOverlay(window.frameElement); |
+ |
deactivateBlockElement(); |
- if (event) |
+ if (target) |
{ |
- getBlockableElementOrAncestor(event.target, element => |
+ getBlockableElementOrAncestor(target, element => |
{ |
if (element) |
{ |