michael@0: // ---------------------------------------------------------------------------- michael@0: // Test whether an InstallTrigger.enabled is working michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); michael@0: waitForFocus(page_loaded, gBrowser.contentWindow); michael@0: }, true); michael@0: gBrowser.loadURI(TESTROOT + "bug638292.html"); michael@0: } michael@0: michael@0: function check_load(aCallback) { michael@0: gBrowser.addEventListener("load", function(aEvent) { michael@0: if (!gBrowser.browsers[2] || michael@0: aEvent.target != gBrowser.browsers[2].contentDocument) { michael@0: // SeaMonkey tabbrowser needs to deal with additional loads. michael@0: if (navigator.userAgent.match(/ SeaMonkey\//)) michael@0: info("Ignoring unrelated load on SeaMonkey. (Expected 2-3 times.)"); michael@0: else michael@0: ok(false, "Ignoring unrelated load on Firefox. (Should never happen!)"); michael@0: return; michael@0: } michael@0: michael@0: gBrowser.removeEventListener("load", arguments.callee, true); michael@0: michael@0: // Let the load handler complete michael@0: executeSoon(function() { michael@0: var doc = gBrowser.browsers[2].contentDocument; michael@0: is(doc.getElementById("enabled").textContent, "true", "installTrigger should have been enabled"); michael@0: michael@0: // Focus the old tab michael@0: gBrowser.selectedTab = gBrowser.tabs[1]; michael@0: waitForFocus(function() { michael@0: // Close the new tab michael@0: gBrowser.removeTab(gBrowser.tabs[2]); michael@0: aCallback(); michael@0: }, gBrowser.contentWindow); michael@0: }); michael@0: }, true); michael@0: } michael@0: michael@0: function page_loaded() { michael@0: var doc = gBrowser.contentDocument; michael@0: info("Clicking link 1"); michael@0: EventUtils.synthesizeMouseAtCenter(doc.getElementById("link1"), { }, gBrowser.contentWindow); michael@0: michael@0: check_load(function() { michael@0: info("Clicking link 2"); michael@0: EventUtils.synthesizeMouseAtCenter(doc.getElementById("link2"), { }, gBrowser.contentWindow); michael@0: michael@0: check_load(function() { michael@0: info("Clicking link 3"); michael@0: EventUtils.synthesizeMouseAtCenter(doc.getElementById("link3"), { button: 1 }, gBrowser.contentWindow); michael@0: michael@0: check_load(function() { michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }); michael@0: }); michael@0: }); michael@0: }