dom/browser-element/mochitest/browserElement_AppWindowNamespace.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* Any copyright is dedicated to the public domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 // Bug 780351 - Test that mozapp divides the window name namespace.
michael@0 5 "use strict";
michael@0 6
michael@0 7 SimpleTest.waitForExplicitFinish();
michael@0 8 browserElementTestHelpers.setEnabledPref(true);
michael@0 9 browserElementTestHelpers.addPermission();
michael@0 10 // Permission to embed an app.
michael@0 11 SpecialPowers.addPermission("embed-apps", true, document);
michael@0 12
michael@0 13 function runTest() {
michael@0 14
michael@0 15 var iframe1 = document.createElement('iframe');
michael@0 16 SpecialPowers.wrap(iframe1).mozbrowser = true;
michael@0 17 iframe1.setAttribute('mozapp', 'http://example.org/manifest.webapp');
michael@0 18
michael@0 19 // Two mozapp frames for different apps with the same code both do the same
michael@0 20 // window.open("foo", "bar") call. We should get two mozbrowseropenwindow
michael@0 21 // events.
michael@0 22
michael@0 23 iframe1.addEventListener('mozbrowseropenwindow', function(e) {
michael@0 24 ok(true, "Got first mozbrowseropenwindow event.");
michael@0 25 document.body.appendChild(e.detail.frameElement);
michael@0 26
michael@0 27 SimpleTest.executeSoon(function() {
michael@0 28 var iframe2 = document.createElement('iframe');
michael@0 29 SpecialPowers.wrap(iframe2).mozbrowser = true;
michael@0 30 iframe2.setAttribute('mozapp', 'http://example.com/manifest.webapp');
michael@0 31
michael@0 32 iframe2.addEventListener('mozbrowseropenwindow', function(e) {
michael@0 33 ok(true, "Got second mozbrowseropenwindow event.");
michael@0 34 SpecialPowers.removePermission("embed-apps", document);
michael@0 35
michael@0 36 // We're not going to open this, but we don't want the platform to either
michael@0 37 e.preventDefault();
michael@0 38 SimpleTest.finish();
michael@0 39 });
michael@0 40
michael@0 41 document.body.appendChild(iframe2);
michael@0 42 iframe2.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html';
michael@0 43 });
michael@0 44 });
michael@0 45
michael@0 46 document.body.appendChild(iframe1);
michael@0 47 iframe1.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html';
michael@0 48 }
michael@0 49
michael@0 50 addEventListener('testready', runTest);

mercurial