2012-09-19 14:28:26 +04:00
|
|
|
/* 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();
|
2013-03-28 23:51:10 +04:00
|
|
|
browserElementTestHelpers.setEnabledPref(true);
|
|
|
|
browserElementTestHelpers.addPermission();
|
2012-09-19 14:28:26 +04:00
|
|
|
|
|
|
|
function runTest() {
|
|
|
|
var iframe1 = document.createElement('iframe');
|
2013-02-27 06:26:10 +04:00
|
|
|
SpecialPowers.wrap(iframe1).mozbrowser = true;
|
2012-09-19 14:28:26 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2012-10-17 08:23:08 +04:00
|
|
|
var domRequest = iframe1.getScreenshot(1000, 1000);
|
2012-09-19 14:28:26 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-03-28 23:51:10 +04:00
|
|
|
addEventListener('testready', runTest);
|