function dispatchClick(target, ctrl) { var e = document.createEvent("MouseEvent");
e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0,
ctrl, false, false, false, 0, null);
target.dispatchEvent(e);
}
function dispatchReturn(target, ctrl) { var e = new KeyboardEvent("keypress", {
bubbles: true,
cancelable: true,
view: window,
ctrlKey: ctrl,
keyCode: 13,
charCode: 0,
});
target.dispatchEvent(e);
}
function dispatchDOMActivate(target) { var e = document.createEvent("UIEvent");
e.initUIEvent("DOMActivate", true, true, window, 0);
target.dispatchEvent(e);
}
var testlink = document.getElementById("testlink");
function test1() {
activationListener =
function() {
ok(true, "Untrusted click should activate a link");
test2();
}
dispatchClick(testlink, false);
}
function test2() {
activationListener =
function() {
ok(true, "Untrusted return keypress should activate a link");
test3();
}
dispatchReturn(testlink, false);
}
function test3() {
activationListener =
function() {
ok(false, "Untrusted click+ctrl should not activate a link");
test4();
}
dispatchClick(testlink, true);
hitEventLoop(10, test4);
}
function test4() {
activationListener =
function() {
ok(false, "Untrusted return keypress+ctrl should not activate a link");
test5();
}
dispatchReturn(testlink, true);
hitEventLoop(10, test5);
}
function test5() {
activationListener =
function() {
ok(true, "click() should activate a link");
test6();
}
testlink.click();
}
function test6() {
activationListener =
function() {
ok(true, "Untrusted DOMActivate should activate a link");
SpecialPowers.pushPrefEnv({"set":[["dom.disable_open_during_load", false]]}, test7);
}
dispatchDOMActivate(testlink);
}
function test7() {
testlink.href = "javascript:opener.activationListener(); window.close();";
testlink.target = "_blank";
testlink.rel = "opener";
activationListener =
function() {
ok(true, "Click() should activate a link");
SpecialPowers.pushPrefEnv({"set":[["dom.disable_open_during_load", true]]}, test8);
}
testlink.click();
}
function test8() {
testlink.href = "javascript:opener.activationListener(); window.close();";
testlink.target = "_blank";
testlink.rel = "opener";
activationListener =
function() {
ok(false, "Click() should not activate a link");
}
testlink.click();
SimpleTest.executeSoon(SimpleTest.finish);
}
addLoadEvent(test1);
</script>
</pre>
</body>
</html>
Messung V0.5
¤ Dauer der Verarbeitung: 0.26 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.