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