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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | function test() { |
michael@0 | 5 | waitForExplicitFinish(); |
michael@0 | 6 | |
michael@0 | 7 | gBrowser.selectedTab = gBrowser.addTab("http://example.org/browser/browser/base/content/test/general/dummy_page.html"); |
michael@0 | 8 | |
michael@0 | 9 | gBrowser.selectedBrowser.addEventListener("load", function runTests() { |
michael@0 | 10 | gBrowser.selectedBrowser.removeEventListener("load", runTests, true); |
michael@0 | 11 | |
michael@0 | 12 | let doc = gBrowser.contentDocument; |
michael@0 | 13 | let base = doc.createElement("base"); |
michael@0 | 14 | doc.head.appendChild(base); |
michael@0 | 15 | |
michael@0 | 16 | let check = function (baseURI, fieldName, expected) { |
michael@0 | 17 | base.href = baseURI; |
michael@0 | 18 | |
michael@0 | 19 | let form = doc.createElement("form"); |
michael@0 | 20 | let element = doc.createElement("input"); |
michael@0 | 21 | element.setAttribute("type", "text"); |
michael@0 | 22 | element.setAttribute("name", fieldName); |
michael@0 | 23 | form.appendChild(element); |
michael@0 | 24 | doc.body.appendChild(form); |
michael@0 | 25 | |
michael@0 | 26 | let data = GetSearchFieldBookmarkData(element); |
michael@0 | 27 | is(data.spec, expected, "Bookmark spec for search field named " + fieldName + " and baseURI " + baseURI + " incorrect"); |
michael@0 | 28 | |
michael@0 | 29 | doc.body.removeChild(form); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | let testData = [ |
michael@0 | 33 | /* baseURI, field name, expected */ |
michael@0 | 34 | [ 'http://example.com/', 'q', 'http://example.com/?q=%s' ], |
michael@0 | 35 | [ 'http://example.com/new-path-here/', 'q', 'http://example.com/new-path-here/?q=%s' ], |
michael@0 | 36 | [ '', 'q', 'http://example.org/browser/browser/base/content/test/general/dummy_page.html?q=%s' ], |
michael@0 | 37 | ] |
michael@0 | 38 | |
michael@0 | 39 | for (let data of testData) { |
michael@0 | 40 | check(data[0], data[1], data[2]); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | // cleanup |
michael@0 | 44 | gBrowser.removeCurrentTab(); |
michael@0 | 45 | finish(); |
michael@0 | 46 | }, true); |
michael@0 | 47 | } |