michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Bug 780351 - Test that mozbrowser does /not/ divide the window name namespace. michael@0: // Multiple mozbrowsers inside the same app are like multiple browser tabs; michael@0: // they share a window name namespace. michael@0: michael@0: "use strict"; michael@0: michael@0: SimpleTest.waitForExplicitFinish(); michael@0: browserElementTestHelpers.setEnabledPref(true); michael@0: browserElementTestHelpers.addPermission(); michael@0: michael@0: function runTest() { michael@0: var iframe1 = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe1).mozbrowser = true; michael@0: michael@0: // Two mozbrowser frames with the same code both do the same michael@0: // window.open("foo", "bar") call. We should only get one michael@0: // mozbrowseropenwindow event. michael@0: michael@0: iframe1.addEventListener('mozbrowseropenwindow', function(e) { michael@0: ok(true, "Got first mozbrowseropenwindow event."); michael@0: document.body.appendChild(e.detail.frameElement); michael@0: michael@0: e.detail.frameElement.addEventListener('mozbrowserlocationchange', function(e) { michael@0: if (e.detail == "http://example.com/#2") { michael@0: ok(true, "Got locationchange to http://example.com/#2"); michael@0: SimpleTest.finish(); michael@0: } michael@0: else { michael@0: ok(true, "Got locationchange to " + e.detail); michael@0: } michael@0: }); michael@0: michael@0: SimpleTest.executeSoon(function() { michael@0: var iframe2 = document.createElement('iframe'); michael@0: SpecialPowers.wrap(iframe2).mozbrowser = true; michael@0: michael@0: iframe2.addEventListener('mozbrowseropenwindow', function(e) { michael@0: ok(false, "Got second mozbrowseropenwindow event."); michael@0: }); michael@0: michael@0: document.body.appendChild(iframe2); michael@0: iframe2.src = 'file_browserElement_BrowserWindowNamespace.html#2'; michael@0: }); michael@0: }); michael@0: michael@0: document.body.appendChild(iframe1); michael@0: iframe1.src = 'file_browserElement_BrowserWindowNamespace.html#1'; michael@0: } michael@0: michael@0: addEventListener('testready', runTest);