dom/browser-element/mochitest/browserElement_FrameWrongURI.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/browser-element/mochitest/browserElement_FrameWrongURI.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* Any copyright is dedicated to the public domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +// Bug 804446 - Test that window.open(javascript:..) works with <iframe mozbrowser>.
     1.8 +
     1.9 +"use strict";
    1.10 +SimpleTest.waitForExplicitFinish();
    1.11 +browserElementTestHelpers.setEnabledPref(true);
    1.12 +browserElementTestHelpers.addPermission();
    1.13 +
    1.14 +function runTest() {
    1.15 +  var iframeJS = document.createElement('iframe');
    1.16 +  SpecialPowers.wrap(iframeJS).mozbrowser = true;
    1.17 +
    1.18 +  iframeJS.addEventListener('mozbrowserloadstart', function(e) {
    1.19 +    ok(false, "This should not happen!");
    1.20 +  });
    1.21 +
    1.22 +  iframeJS.addEventListener('mozbrowserloadend', function(e) {
    1.23 +    ok(false, "This should not happen!");
    1.24 +  });
    1.25 +
    1.26 +  iframeJS.src = 'javascript:alert("Foo");';
    1.27 +  document.body.appendChild(iframeJS);
    1.28 +
    1.29 +  var iframe = document.createElement('iframe');
    1.30 +  SpecialPowers.wrap(iframe).mozbrowser = true;
    1.31 +
    1.32 +  var gotPopup = false;
    1.33 +  iframe.addEventListener('mozbrowseropenwindow', function(e) {
    1.34 +    is(gotPopup, false, 'Should get just one popup.');
    1.35 +    gotPopup = true;
    1.36 +
    1.37 +    document.body.appendChild(e.detail.frameElement);
    1.38 +  });
    1.39 +
    1.40 +  iframe.addEventListener('mozbrowsershowmodalprompt', function(e) {
    1.41 +    ok(gotPopup, 'Got mozbrowseropenwindow event before showmodalprompt event.');
    1.42 +    if (e.detail.message.indexOf("success") == 0) {
    1.43 +      ok(true, e.detail.message);
    1.44 +      SimpleTest.finish();
    1.45 +    }
    1.46 +    else {
    1.47 +      ok(false, "Got invalid message: " + e.detail.message);
    1.48 +    }
    1.49 +  });
    1.50 +
    1.51 +  iframe.src = 'file_browserElement_FrameWrongURI.html';
    1.52 +  document.body.appendChild(iframe);
    1.53 +}
    1.54 +
    1.55 +addEventListener('testready', runTest);

mercurial