|
1 // ---------------------------------------------------------------------------- |
|
2 // Test whether an InstallTrigger.enabled is working |
|
3 function test() { |
|
4 waitForExplicitFinish(); |
|
5 |
|
6 gBrowser.selectedTab = gBrowser.addTab(); |
|
7 gBrowser.selectedBrowser.addEventListener("load", function() { |
|
8 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
9 waitForFocus(page_loaded, gBrowser.contentWindow); |
|
10 }, true); |
|
11 gBrowser.loadURI(TESTROOT + "bug638292.html"); |
|
12 } |
|
13 |
|
14 function check_load(aCallback) { |
|
15 gBrowser.addEventListener("load", function(aEvent) { |
|
16 if (!gBrowser.browsers[2] || |
|
17 aEvent.target != gBrowser.browsers[2].contentDocument) { |
|
18 // SeaMonkey tabbrowser needs to deal with additional loads. |
|
19 if (navigator.userAgent.match(/ SeaMonkey\//)) |
|
20 info("Ignoring unrelated load on SeaMonkey. (Expected 2-3 times.)"); |
|
21 else |
|
22 ok(false, "Ignoring unrelated load on Firefox. (Should never happen!)"); |
|
23 return; |
|
24 } |
|
25 |
|
26 gBrowser.removeEventListener("load", arguments.callee, true); |
|
27 |
|
28 // Let the load handler complete |
|
29 executeSoon(function() { |
|
30 var doc = gBrowser.browsers[2].contentDocument; |
|
31 is(doc.getElementById("enabled").textContent, "true", "installTrigger should have been enabled"); |
|
32 |
|
33 // Focus the old tab |
|
34 gBrowser.selectedTab = gBrowser.tabs[1]; |
|
35 waitForFocus(function() { |
|
36 // Close the new tab |
|
37 gBrowser.removeTab(gBrowser.tabs[2]); |
|
38 aCallback(); |
|
39 }, gBrowser.contentWindow); |
|
40 }); |
|
41 }, true); |
|
42 } |
|
43 |
|
44 function page_loaded() { |
|
45 var doc = gBrowser.contentDocument; |
|
46 info("Clicking link 1"); |
|
47 EventUtils.synthesizeMouseAtCenter(doc.getElementById("link1"), { }, gBrowser.contentWindow); |
|
48 |
|
49 check_load(function() { |
|
50 info("Clicking link 2"); |
|
51 EventUtils.synthesizeMouseAtCenter(doc.getElementById("link2"), { }, gBrowser.contentWindow); |
|
52 |
|
53 check_load(function() { |
|
54 info("Clicking link 3"); |
|
55 EventUtils.synthesizeMouseAtCenter(doc.getElementById("link3"), { button: 1 }, gBrowser.contentWindow); |
|
56 |
|
57 check_load(function() { |
|
58 gBrowser.removeCurrentTab(); |
|
59 finish(); |
|
60 }); |
|
61 }); |
|
62 }); |
|
63 } |