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 /*
2 * Description of the Tests for
3 * - Bug 906190 - Persist "disable protection" option for Mixed Content Blocker in child tabs
4 *
5 * 1. Open a page from the same domain in a child tab
6 * - Load a html page which has mixed content
7 * - Doorhanger to disable protection appears - we disable it
8 * - Load a subpage from the same origin in a new tab simulating a click
9 * - Doorhanger should >> NOT << appear anymore!
10 *
11 * 2. Open a page from a different domain in a child tab
12 * - Load a html page which has mixed content
13 * - Doorhanger to disable protection appears - we disable it
14 * - Load a new page from a different origin in a new tab simulating a click
15 * - Doorhanger >> SHOULD << appear again!
16 *
17 * 3. [meta-refresh: same origin] Open a page from the same domain in a child tab
18 * - Load a html page which has mixed content
19 * - Doorhanger to disable protection appears - we disable it
20 * - Load a new page from the same origin in a new tab simulating a click
21 * - Redirect that page to another page from the same origin using meta-refresh
22 * - Doorhanger should >> NOT << appear again!
23 *
24 * 4. [meta-refresh: different origin] Open a page from a different domain in a child tab
25 * - Load a html page which has mixed content
26 * - Doorhanger to disable protection appears - we disable it
27 * - Load a new page from the same origin in a new tab simulating a click
28 * - Redirect that page to another page from a different origin using meta-refresh
29 * - Doorhanger >> SHOULD << appear again!
30 *
31 * 5. [302 redirect: same origin] Open a page from the same domain in a child tab
32 * - Load a html page which has mixed content
33 * - Doorhanger to disable protection appears - we disable it
34 * - Load a new page from the same origin in a new tab simulating a click
35 * - Redirect that page to another page from the same origin using 302 redirect
36 * - Doorhanger >> APPEARS << , but should >> NOT << appear again!
37 * - FOLLOW UP BUG 914860!
38 *
39 * 6. [302 redirect: different origin] Open a page from the same domain in a child tab
40 * - Load a html page which has mixed content
41 * - Doorhanger to disable protection appears - we disable it
42 * - Load a new page from the same origin in a new tab simulating a click
43 * - Redirect that page to another page from a different origin using 302 redirect
44 * - Doorhanger >> SHOULD << appear again!
45 *
46 * Note, for all tests we set gHttpTestRoot to use 'https' and we test both,
47 * - |CTRL-CLICK|, as well as
48 * - |RIGHT-CLICK->OPEN LINK IN TAB|.
49 */
51 const PREF_ACTIVE = "security.mixed_content.block_active_content";
53 // We use the different urls for testing same origin checks before allowing
54 // mixed content on child tabs.
55 const gHttpTestRoot1 = "https://test1.example.com/browser/browser/base/content/test/general/";
56 const gHttpTestRoot2 = "https://test2.example.com/browser/browser/base/content/test/general/";
58 let origBlockActive;
59 let gTestWin = null;
60 let mainTab = null;
61 let curClickHandler = null;
62 let curContextMenu = null;
63 let curTestFunc = null;
64 let curTestName = null;
65 let curChildTabLink = null;
67 //------------------------ Helper Functions ---------------------
69 registerCleanupFunction(function() {
70 // Set preferences back to their original values
71 Services.prefs.setBoolPref(PREF_ACTIVE, origBlockActive);
72 });
74 /*
75 * Whenever we disable the Mixed Content Blocker of the page
76 * we have to make sure that our condition is properly loaded.
77 */
78 function waitForCondition(condition, nextTest, errorMsg) {
79 var tries = 0;
80 var interval = setInterval(function() {
81 if (tries >= 30) {
82 ok(false, errorMsg);
83 moveOn();
84 }
85 if (condition()) {
86 moveOn();
87 }
88 tries++;
89 }, 100);
90 var moveOn = function() {
91 clearInterval(interval); nextTest();
92 };
93 }
95 // The purpose of this function is to simulate |CTRL+CLICK|.
96 // The clickHandler intercepts simulated user clicks and performs
97 // the |contentAreaClick| which dispatches to handleLinkClick.
98 let clickHandler = function (aEvent, aFunc) {
99 gTestWin.gBrowser.removeEventListener("click", curClickHandler, true);
100 gTestWin.contentAreaClick(aEvent, true);
101 gTestWin.gBrowser.addEventListener("load", aFunc, true);
102 aEvent.preventDefault();
103 aEvent.stopPropagation();
104 }
106 // The purpose of this function is to simulate |RIGHT-CLICK|->|OPEN LINK IN TAB|
107 // Once the contextmenu opens, this functions selects 'open link in tab'
108 // from the contextmenu which dispatches to the function openLinkInTab.
109 let contextMenuOpenHandler = function(aEvent, aFunc) {
110 gTestWin.document.removeEventListener("popupshown", curContextMenu, false);
111 gTestWin.gBrowser.addEventListener("load", aFunc, true);
112 var openLinkInTabCommand = gTestWin.document.getElementById("context-openlinkintab");
113 openLinkInTabCommand.doCommand();
114 aEvent.target.hidePopup();
115 };
117 function setUpTest(aTestName, aIDForNextTest, aFuncForNextTest, aChildTabLink) {
118 curTestName = aTestName;
119 curTestFunc = aFuncForNextTest;
120 curChildTabLink = aChildTabLink;
122 mainTab = gTestWin.gBrowser.selectedTab;
123 // get the link for the next test from the main page
124 let target = gTestWin.content.document.getElementById(aIDForNextTest);
125 gTestWin.gBrowser.addTab(target);
126 gTestWin.gBrowser.selectTabAtIndex(1);
127 gTestWin.gBrowser.addEventListener("load", checkPopUpNotification, true);
128 }
130 function checkPopUpNotification() {
131 gTestWin.gBrowser.removeEventListener("load", checkPopUpNotification, true);
132 gTestWin.gBrowser.addEventListener("load", reloadedTabAfterDisablingMCB, true);
134 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
135 ok(notification, "OK: Mixed Content Doorhanger appeared in " + curTestName + "!");
137 // Disable Mixed Content Protection for the page
138 notification.secondaryActions[0].callback();
139 }
141 function reloadedTabAfterDisablingMCB() {
142 gTestWin.gBrowser.removeEventListener("load", reloadedTabAfterDisablingMCB, true);
144 var expected = "Mixed Content Blocker disabled";
145 waitForCondition(
146 function() gTestWin.content.document.getElementById('mctestdiv').innerHTML == expected,
147 makeSureMCBisDisabled, "Error: Waited too long for mixed script to run in " + curTestName + "!");
148 }
150 function makeSureMCBisDisabled() {
151 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
152 is(actual, "Mixed Content Blocker disabled", "OK: Made sure MCB is disabled in " + curTestName + "!");
154 // inject the provided link into the page, so we can test persistence of MCB
155 let doc = gTestWin.content.document;
156 let mainDiv = gTestWin.content.document.createElement("div");
157 mainDiv.innerHTML =
158 '<p><a id="' + curTestName + '" href="' + curChildTabLink + '">' +
159 curTestName + '</a></p>';
160 doc.body.appendChild(mainDiv);
162 curTestFunc();
163 }
165 //------------------------ Test 1 ------------------------------
167 function test1() {
168 curClickHandler = function (e) { clickHandler(e, test1A) };
169 gTestWin.gBrowser.addEventListener("click", curClickHandler , true);
171 // simulating |CTRL-CLICK|
172 let targetElt = gTestWin.content.document.getElementById("Test1");
173 EventUtils.synthesizeMouseAtCenter(targetElt, { button: 1 }, gTestWin.content);
174 }
176 function test1A() {
177 gTestWin.gBrowser.removeEventListener("load", test1A, true);
178 gTestWin.gBrowser.selectTabAtIndex(2);
180 // The Doorhanger should >> NOT << appear, because our decision of disabling the
181 // mixed content blocker is persistent across tabs.
182 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
183 ok(!notification, "OK: Mixed Content Doorhanger did not appear again in Test 1A!");
185 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
186 is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1A");
188 gTestWin.gBrowser.removeCurrentTab();
189 test1B();
190 }
192 function test1B() {
193 curContextMenu = function (e) { contextMenuOpenHandler(e, test1C) };
194 gTestWin.document.addEventListener("popupshown", curContextMenu, false);
196 // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
197 let targetElt = gTestWin.content.document.getElementById("Test1");
198 // button 2 is a right click, hence the context menu pops up
199 EventUtils.synthesizeMouseAtCenter(targetElt, { type : "contextmenu", button : 2 } , gTestWin.content);
200 }
202 function test1C() {
203 gTestWin.gBrowser.removeEventListener("load", test1C, true);
204 gTestWin.gBrowser.selectTabAtIndex(2);
206 // The Doorhanger should >> NOT << appear, because our decision of disabling the
207 // mixed content blocker is persistent across tabs.
208 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
209 ok(!notification, "OK: Mixed Content Doorhanger did not appear again in Test 1C!");
211 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
212 is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 1C");
214 // remove tabs
215 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
216 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
217 gTestWin.gBrowser.selectTabAtIndex(0);
219 var childTabLink = gHttpTestRoot2 + "file_bug906190_2.html";
220 setUpTest("Test2", "linkForTest2", test2, childTabLink);
221 }
223 //------------------------ Test 2 ------------------------------
225 function test2() {
226 curClickHandler = function (e) { clickHandler(e, test2A) };
227 gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
229 // simulating |CTRL-CLICK|
230 let targetElt = gTestWin.content.document.getElementById("Test2");
231 EventUtils.synthesizeMouseAtCenter(targetElt, { button: 1 }, gTestWin.content);
232 }
234 function test2A() {
235 gTestWin.gBrowser.removeEventListener("load", test2A, true);
236 gTestWin.gBrowser.selectTabAtIndex(2);
238 // The Doorhanger >> SHOULD << appear, because our decision of disabling the
239 // mixed content blocker should only persist if pages are from the same domain.
240 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
241 ok(notification, "OK: Mixed Content Doorhanger did appear again in Test 2A!");
243 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
244 is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2A");
246 gTestWin.gBrowser.removeCurrentTab();
247 test2B();
248 }
250 function test2B() {
251 curContextMenu = function (e) { contextMenuOpenHandler(e, test2C) };
252 gTestWin.document.addEventListener("popupshown", curContextMenu, false);
254 // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
255 let targetElt = gTestWin.content.document.getElementById("Test2");
256 // button 2 is a right click, hence the context menu pops up
257 EventUtils.synthesizeMouseAtCenter(targetElt, { type : "contextmenu", button : 2 } , gTestWin.content);
258 }
260 function test2C() {
261 gTestWin.gBrowser.removeEventListener("load", test2C, true);
262 gTestWin.gBrowser.selectTabAtIndex(2);
264 // The Doorhanger >> SHOULD << appear, because our decision of disabling the
265 // mixed content blocker should only persist if pages are from the same domain.
266 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
267 ok(notification, "OK: Mixed Content Doorhanger did appear again in Test 2C!");
269 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
270 is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 2C");
272 // remove tabs
273 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
274 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
275 gTestWin.gBrowser.selectTabAtIndex(0);
277 // file_bug906190_3_4.html redirects to page test1.example.com/* using meta-refresh
278 var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
279 setUpTest("Test3", "linkForTest3", test3, childTabLink);
280 }
282 //------------------------ Test 3 ------------------------------
284 function test3() {
285 curClickHandler = function (e) { clickHandler(e, test3A) };
286 gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
287 // simulating |CTRL-CLICK|
288 let targetElt = gTestWin.content.document.getElementById("Test3");
289 EventUtils.synthesizeMouseAtCenter(targetElt, { button: 1 }, gTestWin.content);
290 }
292 function test3A() {
293 // we need this indirection because the page is reloaded caused by meta-refresh
294 gTestWin.gBrowser.removeEventListener("load", test3A, true);
295 gTestWin.gBrowser.addEventListener("load", test3B, true);
296 }
298 function test3B() {
299 gTestWin.gBrowser.removeEventListener("load", test3B, true);
300 gTestWin.gBrowser.selectTabAtIndex(2);
302 // The Doorhanger should >> NOT << appear!
303 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
304 ok(!notification, "OK: Mixed Content Doorhanger did appear again in Test 3B!");
306 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
307 is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3B");
309 // remove tabs
310 gTestWin.gBrowser.removeCurrentTab();
311 test3C();
312 }
314 function test3C() {
315 curContextMenu = function (e) { contextMenuOpenHandler(e, test3D) };
316 gTestWin.document.addEventListener("popupshown", curContextMenu, false);
318 // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
319 let targetElt = gTestWin.content.document.getElementById("Test3");
320 EventUtils.synthesizeMouseAtCenter(targetElt, { type : "contextmenu", button : 2 } , gTestWin.content);
321 }
323 function test3D() {
324 // we need this indirection because the page is reloaded caused by meta-refresh
325 gTestWin.gBrowser.removeEventListener("load", test3D, true);
326 gTestWin.gBrowser.addEventListener("load", test3E, true);
327 }
329 function test3E() {
330 gTestWin.gBrowser.removeEventListener("load", test3E, true);
331 gTestWin.gBrowser.selectTabAtIndex(2);
333 // The Doorhanger should >> NOT << appear!
334 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
335 ok(!notification, "OK: Mixed Content Doorhanger did appear again in Test 3E!");
337 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
338 is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 3E");
340 // remove tabs
341 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
342 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
343 gTestWin.gBrowser.selectTabAtIndex(0);
345 var childTabLink = gHttpTestRoot1 + "file_bug906190_3_4.html";
346 setUpTest("Test4", "linkForTest4", test4, childTabLink);
347 }
349 //------------------------ Test 4 ------------------------------
351 function test4() {
352 curClickHandler = function (e) { clickHandler(e, test4A) };
353 gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
355 // simulating |CTRL-CLICK|
356 let targetElt = gTestWin.content.document.getElementById("Test4");
357 EventUtils.synthesizeMouseAtCenter(targetElt, { button: 1 }, gTestWin.content);
358 }
360 function test4A() {
361 // we need this indirection because the page is reloaded caused by meta-refresh
362 gTestWin.gBrowser.removeEventListener("load", test4A, true);
363 gTestWin.gBrowser.addEventListener("load", test4B, true);
364 }
366 function test4B() {
367 gTestWin.gBrowser.removeEventListener("load", test4B, true);
368 gTestWin.gBrowser.selectTabAtIndex(2);
370 // The Doorhanger >> SHOULD << appear!
371 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
372 ok(notification, "OK: Mixed Content Doorhanger did appear again in Test 4B!");
374 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
375 is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4B");
377 // remove tabs
378 gTestWin.gBrowser.removeCurrentTab();
379 test4C();
380 }
382 function test4C() {
383 curContextMenu = function (e) { contextMenuOpenHandler(e, test4D) };
384 gTestWin.document.addEventListener("popupshown", curContextMenu, false);
386 // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
387 let targetElt = gTestWin.content.document.getElementById("Test4");
388 EventUtils.synthesizeMouseAtCenter(targetElt, { type : "contextmenu", button : 2 } , gTestWin.content);
389 }
391 function test4D() {
392 // we need this indirection because the page is reloaded caused by meta-refresh
393 gTestWin.gBrowser.removeEventListener("load", test4D, true);
394 gTestWin.gBrowser.addEventListener("load", test4E, true);
395 }
397 function test4E() {
398 gTestWin.gBrowser.removeEventListener("load", test4E, true);
399 gTestWin.gBrowser.selectTabAtIndex(2);
401 // The Doorhanger >> SHOULD << appear!
402 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
403 ok(notification, "OK: Mixed Content Doorhanger did appear again in Test 4E!");
405 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
406 is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 4E");
408 // remove tabs
409 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
410 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
411 gTestWin.gBrowser.selectTabAtIndex(0);
413 // the sjs files returns a 302 redirect- note, same origins
414 var childTabLink = gHttpTestRoot1 + "file_bug906190.sjs";
415 setUpTest("Test5", "linkForTest5", test5, childTabLink);
416 }
418 //------------------------ Test 5 ------------------------------
420 function test5() {
421 curClickHandler = function (e) { clickHandler(e, test5A) };
422 gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
424 // simulating |CTRL-CLICK|
425 let targetElt = gTestWin.content.document.getElementById("Test5");
426 EventUtils.synthesizeMouseAtCenter(targetElt, { button: 1 }, gTestWin.content);
427 }
429 function test5A() {
430 gTestWin.gBrowser.removeEventListener("load", test5A, true);
431 gTestWin.gBrowser.selectTabAtIndex(2);
433 // The Doorhanger should >> NOT << appear
434 // Currently it >> APPEARS << - see follow up bug 914860
435 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
436 todo(!notification, "OK: Mixed Content Doorhanger did not appear again in Test 5A!");
438 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
439 todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5A!");
441 // remove tabs
442 gTestWin.gBrowser.removeCurrentTab();
443 test5B();
444 }
446 function test5B() {
447 curContextMenu = function (e) { contextMenuOpenHandler(e, test5C) };
448 gTestWin.document.addEventListener("popupshown", curContextMenu, false);
450 // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
451 let targetElt = gTestWin.content.document.getElementById("Test5");
452 EventUtils.synthesizeMouseAtCenter(targetElt, { type : "contextmenu", button : 2 } , gTestWin.content);
453 }
455 function test5C() {
456 gTestWin.gBrowser.removeEventListener("load", test5C, true);
457 // move the tab again
458 gTestWin.gBrowser.selectTabAtIndex(2);
460 // The Doorhanger should >> NOT << appear
461 // Currently it >> APPEARS << - see follow up bug 914860
462 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
463 todo(!notification, "OK: Mixed Content Doorhanger did not appear again in Test 5C!");
465 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
466 todo_is(actual, "Mixed Content Blocker disabled", "OK: Executed mixed script in Test 5C!");
468 // remove tabs
469 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[2], {animate: false});
470 gTestWin.gBrowser.removeTab(gTestWin.gBrowser.tabs[1], {animate: false});
471 gTestWin.gBrowser.selectTabAtIndex(0);
473 // the sjs files returns a 302 redirect - note, different origins
474 var childTabLink = gHttpTestRoot2 + "file_bug906190.sjs";
475 setUpTest("Test6", "linkForTest6", test6, childTabLink);
476 }
478 //------------------------ Test 6 ------------------------------
480 function test6() {
481 curClickHandler = function (e) { clickHandler(e, test6A) };
482 gTestWin.gBrowser.addEventListener("click", curClickHandler, true);
484 // simulating |CTRL-CLICK|
485 let targetElt = gTestWin.content.document.getElementById("Test6");
486 EventUtils.synthesizeMouseAtCenter(targetElt, { button: 1 }, gTestWin.content);
487 }
489 function test6A() {
490 gTestWin.gBrowser.removeEventListener("load", test6A, true);
491 gTestWin.gBrowser.selectTabAtIndex(2);
493 // The Doorhanger >> SHOULD << appear!
494 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
495 ok(notification, "OK: Mixed Content Doorhanger did appear again in Test 6A!");
497 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
498 is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6A");
500 // done
501 gTestWin.gBrowser.removeCurrentTab();
502 test6B();
503 }
505 function test6B() {
506 curContextMenu = function (e) { contextMenuOpenHandler(e, test6C) };
507 gTestWin.document.addEventListener("popupshown", curContextMenu, false);
509 // simulating |RIGHT-CLICK -> OPEN LINK IN TAB|
510 let targetElt = gTestWin.content.document.getElementById("Test6");
511 EventUtils.synthesizeMouseAtCenter(targetElt, { type : "contextmenu", button : 2 } , gTestWin.content);
512 }
514 function test6C() {
515 gTestWin.gBrowser.removeEventListener("load", test6C, true);
516 gTestWin.gBrowser.selectTabAtIndex(2);
518 // The Doorhanger >> SHOULD << appear!
519 var notification = PopupNotifications.getNotification("mixed-content-blocked", gTestWin.gBrowser.selectedBrowser);
520 ok(notification, "OK: Mixed Content Doorhanger did appear again in Test 6C!");
522 var actual = gTestWin.content.document.getElementById('mctestdiv').innerHTML;
523 is(actual, "Mixed Content Blocker enabled", "OK: Blocked mixed script in Test 6C");
525 gTestWin.close();
526 finish();
527 }
529 //------------------------ SETUP ------------------------------
531 function setupTestBrowserWindow() {
532 // Inject links in content.
533 let doc = gTestWin.content.document;
534 let mainDiv = doc.createElement("div");
535 mainDiv.innerHTML =
536 '<p><a id="linkForTest1" href="'+ gHttpTestRoot1 + 'file_bug906190_1.html">Test 1</a></p>' +
537 '<p><a id="linkForTest2" href="'+ gHttpTestRoot1 + 'file_bug906190_2.html">Test 2</a></p>' +
538 '<p><a id="linkForTest3" href="'+ gHttpTestRoot1 + 'file_bug906190_1.html">Test 3</a></p>' +
539 '<p><a id="linkForTest4" href="'+ gHttpTestRoot2 + 'file_bug906190_1.html">Test 4</a></p>' +
540 '<p><a id="linkForTest5" href="'+ gHttpTestRoot1 + 'file_bug906190_1.html">Test 5</a></p>' +
541 '<p><a id="linkForTest6" href="'+ gHttpTestRoot1 + 'file_bug906190_1.html">Test 6</a></p>';
542 doc.body.appendChild(mainDiv);
543 }
545 function startTests() {
546 mainTab = gTestWin.gBrowser.selectedTab;
547 var childTabLink = gHttpTestRoot1 + "file_bug906190_2.html";
548 setUpTest("Test1", "linkForTest1", test1, childTabLink);
549 }
551 function test() {
552 // Performing async calls, e.g. 'onload', we have to wait till all of them finished
553 waitForExplicitFinish();
555 // Store original preferences so we can restore settings after testing
556 origBlockActive = Services.prefs.getBoolPref(PREF_ACTIVE);
557 Services.prefs.setBoolPref(PREF_ACTIVE, true);
559 gTestWin = openDialog(location, "", "chrome,all,dialog=no", "about:blank");
560 whenDelayedStartupFinished(gTestWin, function () {
561 info("browser window opened");
562 waitForFocus(function() {
563 info("browser window focused");
564 waitForFocus(function() {
565 info("setting up browser...");
566 setupTestBrowserWindow();
567 info("running tests...");
568 executeSoon(startTests);
569 }, gTestWin.content, true);
570 }, gTestWin);
571 });
572 }