dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:f439c7aaf492
1 /* Any copyright is dedicated to the public domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 // Bug 780351 - Test that mozbrowser does /not/ divide the window name namespace.
5 // Multiple mozbrowsers inside the same app are like multiple browser tabs;
6 // they share a window name namespace.
7
8 "use strict";
9
10 SimpleTest.waitForExplicitFinish();
11 browserElementTestHelpers.setEnabledPref(true);
12 browserElementTestHelpers.addPermission();
13
14 function runTest() {
15 var iframe1 = document.createElement('iframe');
16 SpecialPowers.wrap(iframe1).mozbrowser = true;
17
18 // Two mozbrowser frames with the same code both do the same
19 // window.open("foo", "bar") call. We should only get one
20 // mozbrowseropenwindow event.
21
22 iframe1.addEventListener('mozbrowseropenwindow', function(e) {
23 ok(true, "Got first mozbrowseropenwindow event.");
24 document.body.appendChild(e.detail.frameElement);
25
26 e.detail.frameElement.addEventListener('mozbrowserlocationchange', function(e) {
27 if (e.detail == "http://example.com/#2") {
28 ok(true, "Got locationchange to http://example.com/#2");
29 SimpleTest.finish();
30 }
31 else {
32 ok(true, "Got locationchange to " + e.detail);
33 }
34 });
35
36 SimpleTest.executeSoon(function() {
37 var iframe2 = document.createElement('iframe');
38 SpecialPowers.wrap(iframe2).mozbrowser = true;
39
40 iframe2.addEventListener('mozbrowseropenwindow', function(e) {
41 ok(false, "Got second mozbrowseropenwindow event.");
42 });
43
44 document.body.appendChild(iframe2);
45 iframe2.src = 'file_browserElement_BrowserWindowNamespace.html#2';
46 });
47 });
48
49 document.body.appendChild(iframe1);
50 iframe1.src = 'file_browserElement_BrowserWindowNamespace.html#1';
51 }
52
53 addEventListener('testready', runTest);

mercurial