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/browser-element/mochitest/browserElement_DOMRequestError.js | |
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/browser-element/mochitest/browserElement_DOMRequestError.js')
-rw-r--r-- | dom/browser-element/mochitest/browserElement_DOMRequestError.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/browserElement_DOMRequestError.js b/dom/browser-element/mochitest/browserElement_DOMRequestError.js new file mode 100644 index 000000000..040cb81fd --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_DOMRequestError.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test if DOMRequest returned by an iframe gets an error callback when +// the iframe is not in the DOM. +"use strict"; + +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); + +function runTest() { + var iframe1 = document.createElement('iframe'); + iframe1.setAttribute('mozbrowser', 'true'); + iframe1.src = 'data:text/html,<html>' + + '<body style="background:green">hello</body></html>'; + document.body.appendChild(iframe1); + + function testIframe(beforeRun, isErrorExpected, nextTest) { + return function() { + var error = false; + if (beforeRun) + beforeRun(); + function testEnd() { + is(isErrorExpected, error); + SimpleTest.executeSoon(nextTest); + } + + var domRequest = iframe1.getScreenshot(1000, 1000); + domRequest.onsuccess = function(e) { + testEnd(); + } + domRequest.onerror = function(e) { + error = true; + testEnd(); + } + }; + } + + function iframeLoadedHandler() { + iframe1.removeEventListener('mozbrowserloadend', iframeLoadedHandler); + // Test 1: iframe is in the DOM. + // Test 2: iframe is removed from the DOM. + // Test 3: iframe is added back into the DOM. + var test3 = testIframe( + function() { + document.body.appendChild(iframe1); + }, false, + function() { + SimpleTest.finish(); + }) + ; + var test2 = testIframe(function() { + document.body.removeChild(iframe1); + }, true, test3); + var test1 = testIframe(null, false, test2); + SimpleTest.executeSoon(test1); + } + + iframe1.addEventListener('mozbrowserloadend', iframeLoadedHandler); +} + +addEventListener('testready', runTest); |