diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/base/test/test_bug1308069.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/base/test/test_bug1308069.html')
-rw-r--r-- | dom/base/test/test_bug1308069.html | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/dom/base/test/test_bug1308069.html b/dom/base/test/test_bug1308069.html new file mode 100644 index 000000000..2775ff1b7 --- /dev/null +++ b/dom/base/test/test_bug1308069.html @@ -0,0 +1,87 @@ +<!DOCTYPE html> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1308069 +--> +<head> +<title>Bug 1308069</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=1308069">Mozilla Bug 1308069</a> +<script class="testbody" type="text/javascript"> + +function testClearPendingErrorEvent() { + return new Promise(function(aResolve, aReject) { + var hasErrorEvent = false; + var imgTarget = new Image(); + + var imgForChangingTargetSrc = new Image(); + // Queue an error event for changing imgTarget's src. + imgForChangingTargetSrc.src = ''; + imgForChangingTargetSrc.onerror = function() { + // This clears imgTarget's pending error event. + imgTarget.src = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96"><path d="M10,10L32,90L90,32z" fill="lightgreen"/></svg>'; + + // Queue an error event for checking and resolving promise. + var imgForCheckingAndResolvingPromise = new Image(); + imgForCheckingAndResolvingPromise.src = ''; + imgForCheckingAndResolvingPromise.onerror = function() { + ok(!hasErrorEvent, + 'Should not receive an error event since the pending error event ' + + 'should be cleared before it fired'); + aResolve(); + }; + }; + + // Setting src to empty string queues an error event. + imgTarget.src = ''; + imgTarget.onerror = function() { + hasErrorEvent = true; + }; + }); +} + +function testReplacePendingErrorEvent() { + return new Promise(function(aResolve) { + var numOfErrorEvent = 0; + var imgTarget = new Image(); + + var imgForChangingTargetSrc = new Image(); + // Queue an error event for changing imgTarget's src. + imgForChangingTargetSrc.src = ''; + imgForChangingTargetSrc.onerror = function() { + // This clears pending error event and fires a new one. + imgTarget.src = ''; + + // Queue an error event for checking and resolving promise. + var imgForCheckingAndResolvingPromise = new Image(); + imgForCheckingAndResolvingPromise.src = ''; + imgForCheckingAndResolvingPromise.onerror = function() { + is(numOfErrorEvent, 1, + 'Should only receive one error event since the first pending error ' + + 'event should be cleared before it fired'); + aResolve(); + }; + }; + + // Setting src to empty string queues an error event. + imgTarget.src = ''; + imgTarget.onerror = function() { + numOfErrorEvent++; + }; + }); +} + +SimpleTest.waitForExplicitFinish(); + +Promise.resolve() +.then(() => testClearPendingErrorEvent()) +.then(() => testReplacePendingErrorEvent()) +.catch((err) => ok(false, "promise rejected: " + err)) +.then(() => SimpleTest.finish()); + +</script> +</body> +</html> |