gecko/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js
Patrick Wang 2cfef0b277 Bug 777384 - Test case r=jlebar
--HG--
extra : rebase_source : 777580f0a22bfb3d9d447097b0f4a379f2b7416b
2012-09-27 01:47:57 +08:00

48 lines
1.7 KiB
JavaScript

/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 780351 - Test that mozapp divides the window name namespace.
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
// Permission to embed an app.
SpecialPowers.addPermission("embed-apps", true, document);
var iframe1 = document.createElement('iframe');
iframe1.mozbrowser = true;
iframe1.setAttribute('mozapp', 'http://example.org/manifest.webapp');
// Two mozapp frames for different apps with the same code both do the same
// window.open("foo", "bar") call. We should get two mozbrowseropenwindow
// events.
iframe1.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, "Got first mozbrowseropenwindow event.");
document.body.appendChild(e.detail.frameElement);
SimpleTest.executeSoon(function() {
var iframe2 = document.createElement('iframe');
iframe2.mozbrowser = true;
iframe2.setAttribute('mozapp', 'http://example.com/manifest.webapp');
iframe2.addEventListener('mozbrowseropenwindow', function(e) {
ok(true, "Got second mozbrowseropenwindow event.");
SpecialPowers.removePermission("embed-apps", document);
SimpleTest.finish();
});
document.body.appendChild(iframe2);
iframe2.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html';
});
});
document.body.appendChild(iframe1);
iframe1.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html';
}
runTest();