dom/browser-element/mochitest/browserElement_BrowserWindowNamespace.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     1 /* Any copyright is dedicated to the public domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     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.
     8 "use strict";
    10 SimpleTest.waitForExplicitFinish();
    11 browserElementTestHelpers.setEnabledPref(true);
    12 browserElementTestHelpers.addPermission();
    14 function runTest() {
    15   var iframe1 = document.createElement('iframe');
    16   SpecialPowers.wrap(iframe1).mozbrowser = true;
    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.
    22   iframe1.addEventListener('mozbrowseropenwindow', function(e) {
    23     ok(true, "Got first mozbrowseropenwindow event.");
    24     document.body.appendChild(e.detail.frameElement);
    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     });
    36     SimpleTest.executeSoon(function() {
    37       var iframe2 = document.createElement('iframe');
    38       SpecialPowers.wrap(iframe2).mozbrowser = true;
    40       iframe2.addEventListener('mozbrowseropenwindow', function(e) {
    41         ok(false, "Got second mozbrowseropenwindow event.");
    42       });
    44       document.body.appendChild(iframe2);
    45       iframe2.src = 'file_browserElement_BrowserWindowNamespace.html#2';
    46     });
    47   });
    49   document.body.appendChild(iframe1);
    50   iframe1.src = 'file_browserElement_BrowserWindowNamespace.html#1';
    51 }
    53 addEventListener('testready', runTest);

mercurial