Wed, 31 Dec 2014 06:09:35 +0100
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 - In <iframe mozbrowser>, test that if we call window.open twice
5 // with the same name, we get only one mozbrowseropenwindow event.
7 "use strict";
8 SimpleTest.waitForExplicitFinish();
9 browserElementTestHelpers.setEnabledPref(true);
10 browserElementTestHelpers.addPermission();
12 var iframe;
13 var popupFrame;
14 function runTest() {
15 iframe = document.createElement('iframe');
16 SpecialPowers.wrap(iframe).mozbrowser = true;
18 var gotPopup = false;
19 iframe.addEventListener('mozbrowseropenwindow', function(e) {
20 is(gotPopup, false, 'Should get just one popup.');
21 gotPopup = true;
22 popupFrame = e.detail.frameElement;
23 is(popupFrame.getAttribute('name'), 'OpenNamed');
25 // Called when file_browserElement_OpenNamed2.html loads into popupFrame.
26 popupFrame.addEventListener('mozbrowsershowmodalprompt', function promptlistener(e) {
27 popupFrame.removeEventListener('mozbrowsershowmodalprompt', promptlistener);
29 ok(gotPopup, 'Got openwindow event before showmodalprompt event.');
30 is(e.detail.message, 'success: loaded');
31 SimpleTest.executeSoon(test2);
32 });
34 document.body.appendChild(popupFrame);
35 });
37 // OpenNamed.html will call
38 //
39 // window.open('file_browserElement_OpenNamed2.html', 'OpenNamed').
40 //
41 // Once that popup loads, we reload OpenNamed.html. That will call
42 // window.open again, but we shouldn't get another openwindow event, because
43 // we're opening into the same named window.
44 iframe.src = 'file_browserElement_OpenNamed.html';
45 document.body.appendChild(iframe);
46 }
48 function test2() {
49 popupFrame.addEventListener('mozbrowsershowmodalprompt', function(e) {
50 is(e.detail.message, 'success: loaded');
51 SimpleTest.finish();
52 });
54 iframe.src = 'file_browserElement_OpenNamed.html?test2';
55 }
57 addEventListener('testready', runTest);