diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/base/test/test_bug587931.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/test_bug587931.html')
-rw-r--r-- | dom/base/test/test_bug587931.html | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/dom/base/test/test_bug587931.html b/dom/base/test/test_bug587931.html new file mode 100644 index 0000000000..0a4b84dec7 --- /dev/null +++ b/dom/base/test/test_bug587931.html @@ -0,0 +1,102 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=587931 +--> +<head> + <title>Test for Bug 587931</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=587931">Mozilla Bug 587931</a> +<pre id="test"> +<script type="application/javascript"> +/** Test for Bug 587931 **/ +SimpleTest.waitForExplicitFinish(); +var afterCount = 0; +var lastBeforeExecute = null; +var expectedCurrentScriptInAfterScriptExecute = null; +function verifyScript(n) { + var curr = document.currentScript; + is(curr, document.getElementById(n), "correct script (" + n + ")"); + is(lastBeforeExecute, curr, "correct beforescript (" + n + ")"); + document.addEventListener("afterscriptexecute", function(event) { + afterCount++; + lastBeforeExecute = null; + is(event.target, curr, "correct afterscript (" + n + ")"); + is(document.currentScript, expectedCurrentScriptInAfterScriptExecute, + "document.currentScript in afterscriptexecute(" + n + ")"); + document.removeEventListener("afterscriptexecute", arguments.callee); + }); +} +document.onbeforescriptexecute = function(event) { + lastBeforeExecute = event.target; +}; + +window.addEventListener("load", function() { + is(afterCount, 4, "correct number of afterscriptexecute"); + SimpleTest.finish(); +}); +</script> +</pre> +<!-- Test parser inserted scripts --> +<script id="parse-inline"> +verifyScript("parse-inline"); +</script> +<script id="parse-ext" src="data:text/plain,verifyScript('parse-ext');"></script> + +<!-- Test DOM inserted scripts --> +<script> +var s = document.createElement("script"); +s.textContent = "verifyScript('dom-inline');"; +s.id = "dom-inline"; +expectedCurrentScriptInAfterScriptExecute = document.currentScript; +document.body.appendChild(s); +expectedCurrentScriptInAfterScriptExecute = null; + +s = document.createElement("script"); +s.src = "data:text/plain,verifyScript('dom-ext');"; +s.id = "dom-ext"; +document.body.appendChild(s); +</script> + +<!-- Test cancel using beforescriptexecute --> +<script onbeforescriptexecute="return false;" + onafterescriptexecute="window.firedAfterScriptExecuteForCancel = true;"> +ok(false, "should have been canceled"); +</script> +<script> +isnot(window.firedAfterScriptExecuteForCancel, true, "onafterscriptexecute executed"); +</script> + +<!-- Test cancel using beforescriptexecute for external --> +<script onbeforescriptexecute="return false;" + onafterescriptexecute="window.extFiredAfterScriptExecuteForCancel = true;" + onload="window.extFiredLoadForCancel = true;" + src="data:text/plain,ok(false, 'should have been canceled');"> +</script> +<script> +isnot(window.extFiredAfterScriptExecuteForCancel, true, "onafterscriptexecute executed"); +is(extFiredLoadForCancel, true, "onload executed"); +</script> + +<!-- Test that all events fire --> +<script onbeforescriptexecute="window.beforeDidExecute = true;" + onafterscriptexecute="window.afterDidExecute = true;" + onload="window.loadDidExecute = true" + onerror="window.errorDidExecute = true" + src="data:text/plain, +is(window.beforeDidExecute, true, 'onbeforescriptexecute executed'); +isnot(window.afterDidExecute, true, 'onafterscriptexecute executed'); +isnot(window.loadDidExecute, true, 'onload executed'); +isnot(window.errorDidExecute, true, 'onerror executed'); +"> +</script> +<script> +is(afterDidExecute, true, "onafterscriptexecute executed"); +is(loadDidExecute, true, "onload executed"); +isnot(window.errorDidExecute, true, "onerror executed"); +</script> +</body> +</html> |