dom/browser-element/mochitest/browserElement_OpenWindowRejected.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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