2012-06-13 02:01:25 +04:00
|
|
|
/* Any copyright is dedicated to the public domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
// Bug 742944 - Do window.open from inside <iframe mozbrowser>. But then
|
|
|
|
// reject the call. This shouldn't cause problems (crashes, leaks).
|
|
|
|
//
|
|
|
|
// This is the same as OpenWindowRejected, except we "reject" the popup by not
|
|
|
|
// adding the iframe element to our DOM, instead of by not calling
|
|
|
|
// preventDefault() on the event.
|
|
|
|
|
|
|
|
"use strict";
|
2019-03-19 23:56:24 +03:00
|
|
|
|
|
|
|
/* global browserElementTestHelpers */
|
|
|
|
|
2012-06-13 02:01:25 +04:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2013-03-28 23:51:10 +04:00
|
|
|
browserElementTestHelpers.setEnabledPref(true);
|
|
|
|
browserElementTestHelpers.addPermission();
|
2012-06-13 02:01:25 +04:00
|
|
|
|
|
|
|
function runTest() {
|
2019-03-19 23:56:10 +03:00
|
|
|
var iframe = document.createElement("iframe");
|
|
|
|
iframe.setAttribute("mozbrowser", "true");
|
2012-06-13 02:01:25 +04:00
|
|
|
|
2019-03-19 23:56:10 +03:00
|
|
|
iframe.addEventListener("mozbrowseropenwindow", function(e) {
|
|
|
|
ok(
|
|
|
|
e.detail.url.includes("does_not_exist.html"),
|
|
|
|
"Opened URL; got " + e.detail.url
|
|
|
|
);
|
|
|
|
is(e.detail.name, "");
|
|
|
|
is(e.detail.features, "");
|
2012-06-13 02:01:25 +04:00
|
|
|
|
|
|
|
// Call preventDefault, but don't add the iframe to the DOM. This still
|
|
|
|
// amounts to rejecting the popup.
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
2019-03-19 23:56:10 +03:00
|
|
|
iframe.addEventListener("mozbrowsershowmodalprompt", function(e) {
|
2012-06-13 02:01:25 +04:00
|
|
|
var msg = e.detail.message;
|
2019-03-19 23:56:10 +03:00
|
|
|
if (msg.indexOf("success:") == 0) {
|
2012-06-13 02:01:25 +04:00
|
|
|
ok(true, msg);
|
2019-03-19 23:56:10 +03:00
|
|
|
} else if (msg == "finish") {
|
2012-06-13 02:01:25 +04:00
|
|
|
SimpleTest.finish();
|
2019-03-19 23:56:10 +03:00
|
|
|
} else {
|
2012-06-13 02:01:25 +04:00
|
|
|
ok(false, msg);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-03-19 23:56:10 +03:00
|
|
|
iframe.src = "file_browserElement_OpenWindowRejected.html";
|
2012-06-13 02:01:25 +04:00
|
|
|
}
|
|
|
|
|
2019-03-19 23:56:10 +03:00
|
|
|
addEventListener("testready", runTest);
|