michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Ci = Components.interfaces; michael@0: michael@0: let tab, browser; michael@0: michael@0: function test () { michael@0: waitForExplicitFinish(); michael@0: michael@0: tab = gBrowser.addTab("data:text/html;base64," + michael@0: btoa("" + michael@0: "test link")); michael@0: browser = gBrowser.getBrowserForTab(tab); michael@0: gBrowser.selectedTab = tab; michael@0: michael@0: browser.addEventListener("load", startTests, true); michael@0: } michael@0: michael@0: var outlineTest = "sendAsyncMessage(\"OutlineTest\", " + michael@0: "{ ok : !!content.document." + michael@0: "getElementsByTagName(\"a\")[0].style.outline }" + michael@0: ");"; michael@0: michael@0: function startTests () { michael@0: browser.removeEventListener("load", startTests, true); michael@0: michael@0: let finder = browser.finder; michael@0: let listener = { michael@0: onFindResult: function () { michael@0: ok(false, "callback wasn't replaced"); michael@0: } michael@0: }; michael@0: finder.addResultListener(listener); michael@0: michael@0: listener.onFindResult = function ({result}) { michael@0: ok(result == Ci.nsITypeAheadFind.FIND_FOUND, "should find string"); michael@0: michael@0: listener.onFindResult = function ({result}) { michael@0: ok(result == Ci.nsITypeAheadFind.FIND_NOTFOUND, "should not find string"); michael@0: michael@0: let first = true; michael@0: listener.onFindResult = function ({result}) { michael@0: ok(result == Ci.nsITypeAheadFind.FIND_FOUND, "should find link"); michael@0: michael@0: browser.messageManager.addMessageListener("OutlineTest", function f(aMessage) { michael@0: browser.messageManager.removeMessageListener("OutlineTest", f); michael@0: michael@0: michael@0: if (first) { michael@0: ok(aMessage.data.ok, "content script should send okay"); michael@0: first = false; michael@0: michael@0: // Just a simple search for "test link". michael@0: finder.fastFind("test link", false, false); michael@0: } else { michael@0: ok(!aMessage.data.ok, "content script should not send okay"); michael@0: cleanup(); michael@0: } michael@0: }) michael@0: browser.messageManager.loadFrameScript("data:," + outlineTest, false) michael@0: } michael@0: // Search only for links and draw outlines. michael@0: finder.fastFind("test link", true, true); michael@0: } michael@0: finder.highlight(true, "Bla"); michael@0: } michael@0: finder.highlight(true, "content"); michael@0: } michael@0: michael@0: function cleanup() { michael@0: gBrowser.removeTab(tab); michael@0: finish(); michael@0: }