window XRayWrapper, , , -. , , , - , window.
unsafeWindow.isInstalled = ... ( .isInstalled , , , -).
docs XRayWrapper unsafeWindow.
, @canuckistani:
unsafeWindow , ( script). Spidermonkey . Spidermonkey Gecko. ( , Spidermonkey. IIRC , . ).
, , -. unsafeWindow pwnd.
, , .
. , , :
for (var el of window.document.querySelectorAll("*[onclick]")) {
el.addEventListener("click", el.getAttribute("onclick"));
el.removeAttribute("onclick");
}
( ) - (.getAttribute) script, -.
, unsafeWindow :
for (var el of unsafeWindow.document.querySelectorAll("p")) {
el.addEventListener("click", 'alert("I am ' + el.clientHeight + 'px tall");');
el.removeAttribute("onclick");
}
XRayWrapper wrapped window , document , document.querySelectorAll , , el.clientHeight .
unsafeWindow, . , - - :
document.querySelectorAll = function() {
return [{
clientHeight: 'a pwnd content script"); doSomethingEvil(); alert("Now I own you! And I am certainly not 0'
}];
};
, - unsafeWindow.document.querySelectorAll, ( ) -, .
script , , . . .
Object.defineProperty(document, "title", {
get: function() { while(true); }
});
Object.defineProperty(document, "title", {
get: function() { throw new Error("get off my lawn!"); }
});