dom/browser-element/mochitest/browserElement_FrameWrongURI.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 804446 - Test that window.open(javascript:..) works with <iframe mozbrowser>.
     6 "use strict";
     7 SimpleTest.waitForExplicitFinish();
     8 browserElementTestHelpers.setEnabledPref(true);
     9 browserElementTestHelpers.addPermission();
    11 function runTest() {
    12   var iframeJS = document.createElement('iframe');
    13   SpecialPowers.wrap(iframeJS).mozbrowser = true;
    15   iframeJS.addEventListener('mozbrowserloadstart', function(e) {
    16     ok(false, "This should not happen!");
    17   });
    19   iframeJS.addEventListener('mozbrowserloadend', function(e) {
    20     ok(false, "This should not happen!");
    21   });
    23   iframeJS.src = 'javascript:alert("Foo");';
    24   document.body.appendChild(iframeJS);
    26   var iframe = document.createElement('iframe');
    27   SpecialPowers.wrap(iframe).mozbrowser = true;
    29   var gotPopup = false;
    30   iframe.addEventListener('mozbrowseropenwindow', function(e) {
    31     is(gotPopup, false, 'Should get just one popup.');
    32     gotPopup = true;
    34     document.body.appendChild(e.detail.frameElement);
    35   });
    37   iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
    38     ok(gotPopup, 'Got mozbrowseropenwindow event before showmodalprompt event.');
    39     if (e.detail.message.indexOf("success") == 0) {
    40       ok(true, e.detail.message);
    41       SimpleTest.finish();
    42     }
    43     else {
    44       ok(false, "Got invalid message: " + e.detail.message);
    45     }
    46   });
    48   iframe.src = 'file_browserElement_FrameWrongURI.html';
    49   document.body.appendChild(iframe);
    50 }
    52 addEventListener('testready', runTest);

mercurial