dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial