1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Test whether an InstallTrigger.enabled is working 1.6 +function test() { 1.7 + waitForExplicitFinish(); 1.8 + 1.9 + gBrowser.selectedTab = gBrowser.addTab(); 1.10 + gBrowser.selectedBrowser.addEventListener("load", function() { 1.11 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.12 + waitForFocus(page_loaded, gBrowser.contentWindow); 1.13 + }, true); 1.14 + gBrowser.loadURI(TESTROOT + "bug638292.html"); 1.15 +} 1.16 + 1.17 +function check_load(aCallback) { 1.18 + gBrowser.addEventListener("load", function(aEvent) { 1.19 + if (!gBrowser.browsers[2] || 1.20 + aEvent.target != gBrowser.browsers[2].contentDocument) { 1.21 + // SeaMonkey tabbrowser needs to deal with additional loads. 1.22 + if (navigator.userAgent.match(/ SeaMonkey\//)) 1.23 + info("Ignoring unrelated load on SeaMonkey. (Expected 2-3 times.)"); 1.24 + else 1.25 + ok(false, "Ignoring unrelated load on Firefox. (Should never happen!)"); 1.26 + return; 1.27 + } 1.28 + 1.29 + gBrowser.removeEventListener("load", arguments.callee, true); 1.30 + 1.31 + // Let the load handler complete 1.32 + executeSoon(function() { 1.33 + var doc = gBrowser.browsers[2].contentDocument; 1.34 + is(doc.getElementById("enabled").textContent, "true", "installTrigger should have been enabled"); 1.35 + 1.36 + // Focus the old tab 1.37 + gBrowser.selectedTab = gBrowser.tabs[1]; 1.38 + waitForFocus(function() { 1.39 + // Close the new tab 1.40 + gBrowser.removeTab(gBrowser.tabs[2]); 1.41 + aCallback(); 1.42 + }, gBrowser.contentWindow); 1.43 + }); 1.44 + }, true); 1.45 +} 1.46 + 1.47 +function page_loaded() { 1.48 + var doc = gBrowser.contentDocument; 1.49 + info("Clicking link 1"); 1.50 + EventUtils.synthesizeMouseAtCenter(doc.getElementById("link1"), { }, gBrowser.contentWindow); 1.51 + 1.52 + check_load(function() { 1.53 + info("Clicking link 2"); 1.54 + EventUtils.synthesizeMouseAtCenter(doc.getElementById("link2"), { }, gBrowser.contentWindow); 1.55 + 1.56 + check_load(function() { 1.57 + info("Clicking link 3"); 1.58 + EventUtils.synthesizeMouseAtCenter(doc.getElementById("link3"), { button: 1 }, gBrowser.contentWindow); 1.59 + 1.60 + check_load(function() { 1.61 + gBrowser.removeCurrentTab(); 1.62 + finish(); 1.63 + }); 1.64 + }); 1.65 + }); 1.66 +}