dom/browser-element/mochitest/browserElement_OpenWindowRejected.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.

     1 /* Any copyright is dedicated to the public domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // Bug 742944 - Do window.open from inside <iframe mozbrowser>.  But then
     5 // reject the call.  This shouldn't cause problems (crashes, leaks).
     7 "use strict";
     8 SimpleTest.waitForExplicitFinish();
     9 browserElementTestHelpers.setEnabledPref(true);
    10 browserElementTestHelpers.addPermission();
    12 function runTest() {
    13   var iframe = document.createElement('iframe');
    14   SpecialPowers.wrap(iframe).mozbrowser = true;
    16   iframe.addEventListener('mozbrowseropenwindow', function(e) {
    17     ok(e.detail.url.indexOf('does_not_exist.html') != -1,
    18        'Opened URL; got ' + e.detail.url);
    19     is(e.detail.name, '');
    20     is(e.detail.features, '');
    22     // Don't add e.detail.frameElement to the DOM, so the window.open is
    23     // effectively blocked.
    24     e.preventDefault();
    25   });
    27   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
    28     var msg = e.detail.message;
    29     if (msg.indexOf('success:') == 0) {
    30       ok(true, msg);
    31     }
    32     else if (msg == 'finish') {
    33       SimpleTest.finish();
    34     }
    35     else {
    36       ok(false, msg);
    37     }
    38   });
    40   iframe.src = 'file_browserElement_OpenWindowRejected.html';
    41   document.body.appendChild(iframe);
    42 }
    44 addEventListener('testready', runTest);

mercurial