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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | const Ci = Components.interfaces; |
michael@0 | 6 | |
michael@0 | 7 | let tab, browser; |
michael@0 | 8 | |
michael@0 | 9 | function test () { |
michael@0 | 10 | waitForExplicitFinish(); |
michael@0 | 11 | |
michael@0 | 12 | tab = gBrowser.addTab("data:text/html;base64," + |
michael@0 | 13 | btoa("<body><iframe srcdoc=\"content\"/></iframe>" + |
michael@0 | 14 | "<a href=\"http://test.com\">test link</a>")); |
michael@0 | 15 | browser = gBrowser.getBrowserForTab(tab); |
michael@0 | 16 | gBrowser.selectedTab = tab; |
michael@0 | 17 | |
michael@0 | 18 | browser.addEventListener("load", startTests, true); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | var outlineTest = "sendAsyncMessage(\"OutlineTest\", " + |
michael@0 | 22 | "{ ok : !!content.document." + |
michael@0 | 23 | "getElementsByTagName(\"a\")[0].style.outline }" + |
michael@0 | 24 | ");"; |
michael@0 | 25 | |
michael@0 | 26 | function startTests () { |
michael@0 | 27 | browser.removeEventListener("load", startTests, true); |
michael@0 | 28 | |
michael@0 | 29 | let finder = browser.finder; |
michael@0 | 30 | let listener = { |
michael@0 | 31 | onFindResult: function () { |
michael@0 | 32 | ok(false, "callback wasn't replaced"); |
michael@0 | 33 | } |
michael@0 | 34 | }; |
michael@0 | 35 | finder.addResultListener(listener); |
michael@0 | 36 | |
michael@0 | 37 | listener.onFindResult = function ({result}) { |
michael@0 | 38 | ok(result == Ci.nsITypeAheadFind.FIND_FOUND, "should find string"); |
michael@0 | 39 | |
michael@0 | 40 | listener.onFindResult = function ({result}) { |
michael@0 | 41 | ok(result == Ci.nsITypeAheadFind.FIND_NOTFOUND, "should not find string"); |
michael@0 | 42 | |
michael@0 | 43 | let first = true; |
michael@0 | 44 | listener.onFindResult = function ({result}) { |
michael@0 | 45 | ok(result == Ci.nsITypeAheadFind.FIND_FOUND, "should find link"); |
michael@0 | 46 | |
michael@0 | 47 | browser.messageManager.addMessageListener("OutlineTest", function f(aMessage) { |
michael@0 | 48 | browser.messageManager.removeMessageListener("OutlineTest", f); |
michael@0 | 49 | |
michael@0 | 50 | |
michael@0 | 51 | if (first) { |
michael@0 | 52 | ok(aMessage.data.ok, "content script should send okay"); |
michael@0 | 53 | first = false; |
michael@0 | 54 | |
michael@0 | 55 | // Just a simple search for "test link". |
michael@0 | 56 | finder.fastFind("test link", false, false); |
michael@0 | 57 | } else { |
michael@0 | 58 | ok(!aMessage.data.ok, "content script should not send okay"); |
michael@0 | 59 | cleanup(); |
michael@0 | 60 | } |
michael@0 | 61 | }) |
michael@0 | 62 | browser.messageManager.loadFrameScript("data:," + outlineTest, false) |
michael@0 | 63 | } |
michael@0 | 64 | // Search only for links and draw outlines. |
michael@0 | 65 | finder.fastFind("test link", true, true); |
michael@0 | 66 | } |
michael@0 | 67 | finder.highlight(true, "Bla"); |
michael@0 | 68 | } |
michael@0 | 69 | finder.highlight(true, "content"); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function cleanup() { |
michael@0 | 73 | gBrowser.removeTab(tab); |
michael@0 | 74 | finish(); |
michael@0 | 75 | } |