1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/* Any copyright is dedicated to the public domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Bug 780351 - Test that mozapp divides the window name namespace. 1.8 +"use strict"; 1.9 + 1.10 +SimpleTest.waitForExplicitFinish(); 1.11 +browserElementTestHelpers.setEnabledPref(true); 1.12 +browserElementTestHelpers.addPermission(); 1.13 +// Permission to embed an app. 1.14 +SpecialPowers.addPermission("embed-apps", true, document); 1.15 + 1.16 +function runTest() { 1.17 + 1.18 + var iframe1 = document.createElement('iframe'); 1.19 + SpecialPowers.wrap(iframe1).mozbrowser = true; 1.20 + iframe1.setAttribute('mozapp', 'http://example.org/manifest.webapp'); 1.21 + 1.22 + // Two mozapp frames for different apps with the same code both do the same 1.23 + // window.open("foo", "bar") call. We should get two mozbrowseropenwindow 1.24 + // events. 1.25 + 1.26 + iframe1.addEventListener('mozbrowseropenwindow', function(e) { 1.27 + ok(true, "Got first mozbrowseropenwindow event."); 1.28 + document.body.appendChild(e.detail.frameElement); 1.29 + 1.30 + SimpleTest.executeSoon(function() { 1.31 + var iframe2 = document.createElement('iframe'); 1.32 + SpecialPowers.wrap(iframe2).mozbrowser = true; 1.33 + iframe2.setAttribute('mozapp', 'http://example.com/manifest.webapp'); 1.34 + 1.35 + iframe2.addEventListener('mozbrowseropenwindow', function(e) { 1.36 + ok(true, "Got second mozbrowseropenwindow event."); 1.37 + SpecialPowers.removePermission("embed-apps", document); 1.38 + 1.39 + // We're not going to open this, but we don't want the platform to either 1.40 + e.preventDefault(); 1.41 + SimpleTest.finish(); 1.42 + }); 1.43 + 1.44 + document.body.appendChild(iframe2); 1.45 + iframe2.src = 'http://example.com/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html'; 1.46 + }); 1.47 + }); 1.48 + 1.49 + document.body.appendChild(iframe1); 1.50 + iframe1.src = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html'; 1.51 +} 1.52 + 1.53 +addEventListener('testready', runTest);