diff --git a/dom/browser-element/mochitest/Makefile.in b/dom/browser-element/mochitest/Makefile.in index f215be686c1..9256dc636bd 100644 --- a/dom/browser-element/mochitest/Makefile.in +++ b/dom/browser-element/mochitest/Makefile.in @@ -33,6 +33,12 @@ MOCHITEST_FILES = \ test_browserElement_inproc_Titlechange.html \ browserElement_TopBarrier.js \ test_browserElement_inproc_TopBarrier.html \ + browserElement_AppWindowNamespace.js \ + test_browserElement_inproc_AppWindowNamespace.html \ + file_browserElement_AppWindowNamespace.html \ + browserElement_BrowserWindowNamespace.js \ + test_browserElement_inproc_BrowserWindowNamespace.html \ + file_browserElement_BrowserWindowNamespace.html \ browserElement_Iconchange.js \ test_browserElement_inproc_Iconchange.html \ browserElement_GetScreenshot.js \ @@ -122,6 +128,8 @@ MOCHITEST_FILES += \ test_browserElement_oop_DataURI.html \ test_browserElement_oop_ErrorSecurity.html \ test_browserElement_oop_Titlechange.html \ + test_browserElement_oop_AppWindowNamespace.html \ + test_browserElement_oop_BrowserWindowNamespace.html \ test_browserElement_oop_TopBarrier.html \ test_browserElement_oop_Iconchange.html \ test_browserElement_oop_GetScreenshot.html \ diff --git a/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js b/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js new file mode 100644 index 00000000000..f6fcaa08e40 --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_AppWindowNamespace.js @@ -0,0 +1,44 @@ +/* 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.addToWhitelist(); + + 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."); + 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(); diff --git a/dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js b/dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js new file mode 100644 index 00000000000..3dc61d2ab2c --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js @@ -0,0 +1,54 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Bug 780351 - Test that mozbrowser does /not/ divide the window name namespace. +// Multiple mozbrowsers inside the same app are like multiple browser tabs; +// they share a window name namespace. + +"use strict"; + +SimpleTest.waitForExplicitFinish(); + +function runTest() { + browserElementTestHelpers.setEnabledPref(true); + browserElementTestHelpers.addToWhitelist(); + + var iframe1 = document.createElement('iframe'); + iframe1.mozbrowser = true; + + // Two mozbrowser frames with the same code both do the same + // window.open("foo", "bar") call. We should only get one + // mozbrowseropenwindow event. + + iframe1.addEventListener('mozbrowseropenwindow', function(e) { + ok(true, "Got first mozbrowseropenwindow event."); + document.body.appendChild(e.detail.frameElement); + + e.detail.frameElement.addEventListener('mozbrowserlocationchange', function(e) { + if (e.detail == "http://example.com/#2") { + ok(true, "Got locationchange to http://example.com/#2"); + SimpleTest.finish(); + } + else { + ok(true, "Got locationchange to " + e.detail); + } + }); + + SimpleTest.executeSoon(function() { + var iframe2 = document.createElement('iframe'); + iframe2.mozbrowser = true; + + iframe2.addEventListener('mozbrowseropenwindow', function(e) { + ok(false, "Got second mozbrowseropenwindow event."); + }); + + document.body.appendChild(iframe2); + iframe2.src = 'file_browserElement_BrowserWindowNamespace.html#2'; + }); + }); + + document.body.appendChild(iframe1); + iframe1.src = 'file_browserElement_BrowserWindowNamespace.html#1'; +} + +runTest(); diff --git a/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html b/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html new file mode 100644 index 00000000000..7643cb85b7a --- /dev/null +++ b/dom/browser-element/mochitest/file_browserElement_AppWindowNamespace.html @@ -0,0 +1,7 @@ + +
+ + + diff --git a/dom/browser-element/mochitest/file_browserElement_BrowserWindowNamespace.html b/dom/browser-element/mochitest/file_browserElement_BrowserWindowNamespace.html new file mode 100644 index 00000000000..f0379d9099d --- /dev/null +++ b/dom/browser-element/mochitest/file_browserElement_BrowserWindowNamespace.html @@ -0,0 +1,7 @@ + + + + + diff --git a/dom/browser-element/mochitest/test_browserElement_inproc_AppWindowNamespace.html b/dom/browser-element/mochitest/test_browserElement_inproc_AppWindowNamespace.html new file mode 100644 index 00000000000..029e320c20c --- /dev/null +++ b/dom/browser-element/mochitest/test_browserElement_inproc_AppWindowNamespace.html @@ -0,0 +1,13 @@ + + + +