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

michael@0 1 /* Any copyright is dedicated to the public domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 // Bug 742944 - In <iframe mozbrowser>, test that if we call window.open twice
michael@0 5 // with the same name, we get only one mozbrowseropenwindow event.
michael@0 6
michael@0 7 "use strict";
michael@0 8 SimpleTest.waitForExplicitFinish();
michael@0 9 browserElementTestHelpers.setEnabledPref(true);
michael@0 10 browserElementTestHelpers.addPermission();
michael@0 11
michael@0 12 var iframe;
michael@0 13 var popupFrame;
michael@0 14 function runTest() {
michael@0 15 iframe = document.createElement('iframe');
michael@0 16 SpecialPowers.wrap(iframe).mozbrowser = true;
michael@0 17
michael@0 18 var gotPopup = false;
michael@0 19 iframe.addEventListener('mozbrowseropenwindow', function(e) {
michael@0 20 is(gotPopup, false, 'Should get just one popup.');
michael@0 21 gotPopup = true;
michael@0 22 popupFrame = e.detail.frameElement;
michael@0 23 is(popupFrame.getAttribute('name'), 'OpenNamed');
michael@0 24
michael@0 25 // Called when file_browserElement_OpenNamed2.html loads into popupFrame.
michael@0 26 popupFrame.addEventListener('mozbrowsershowmodalprompt', function promptlistener(e) {
michael@0 27 popupFrame.removeEventListener('mozbrowsershowmodalprompt', promptlistener);
michael@0 28
michael@0 29 ok(gotPopup, 'Got openwindow event before showmodalprompt event.');
michael@0 30 is(e.detail.message, 'success: loaded');
michael@0 31 SimpleTest.executeSoon(test2);
michael@0 32 });
michael@0 33
michael@0 34 document.body.appendChild(popupFrame);
michael@0 35 });
michael@0 36
michael@0 37 // OpenNamed.html will call
michael@0 38 //
michael@0 39 // window.open('file_browserElement_OpenNamed2.html', 'OpenNamed').
michael@0 40 //
michael@0 41 // Once that popup loads, we reload OpenNamed.html. That will call
michael@0 42 // window.open again, but we shouldn't get another openwindow event, because
michael@0 43 // we're opening into the same named window.
michael@0 44 iframe.src = 'file_browserElement_OpenNamed.html';
michael@0 45 document.body.appendChild(iframe);
michael@0 46 }
michael@0 47
michael@0 48 function test2() {
michael@0 49 popupFrame.addEventListener('mozbrowsershowmodalprompt', function(e) {
michael@0 50 is(e.detail.message, 'success: loaded');
michael@0 51 SimpleTest.finish();
michael@0 52 });
michael@0 53
michael@0 54 iframe.src = 'file_browserElement_OpenNamed.html?test2';
michael@0 55 }
michael@0 56
michael@0 57 addEventListener('testready', runTest);

mercurial