From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- .../content/test/urlbar/browser_urlHighlight.js | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 browser/base/content/test/urlbar/browser_urlHighlight.js (limited to 'browser/base/content/test/urlbar/browser_urlHighlight.js') diff --git a/browser/base/content/test/urlbar/browser_urlHighlight.js b/browser/base/content/test/urlbar/browser_urlHighlight.js new file mode 100644 index 000000000..ba1537d91 --- /dev/null +++ b/browser/base/content/test/urlbar/browser_urlHighlight.js @@ -0,0 +1,134 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +function testVal(aExpected) { + gURLBar.value = aExpected.replace(/[<>]/g, ""); + + let selectionController = gURLBar.editor.selectionController; + let selection = selectionController.getSelection(selectionController.SELECTION_URLSECONDARY); + let value = gURLBar.editor.rootElement.textContent; + let result = ""; + for (let i = 0; i < selection.rangeCount; i++) { + let range = selection.getRangeAt(i).toString(); + let pos = value.indexOf(range); + result += value.substring(0, pos) + "<" + range + ">"; + value = value.substring(pos + range.length); + } + result += value; + is(result, aExpected, + "Correct part of the urlbar contents is highlighted"); +} + +function test() { + const prefname = "browser.urlbar.formatting.enabled"; + + registerCleanupFunction(function () { + Services.prefs.clearUserPref(prefname); + URLBarSetURI(); + }); + + Services.prefs.setBoolPref(prefname, true); + + gURLBar.focus(); + + testVal("https://mozilla.org"); + + gBrowser.selectedBrowser.focus(); + + testVal("mozilla.org"); + testVal("mözilla.org"); + testVal("mozilla.imaginatory"); + + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.com"); + testVal("mozilla.com"); + testVal("mozilla.com"); + + testVal("mozilla.org"); + testVal("mozilla.org"); + + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + + testVal("mozilla.org< >"); + testVal("mozilla.org< >"); + + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("foo.bar"); + testVal("foo.bar<#mozilla.org>"); + testVal("foo.bar"); + testVal("foo.bar"); + testVal("foo.bar<#x@mozilla.org>"); + testVal("foo.bar<#@x@mozilla.org>"); + testVal("foo.bar"); + testVal("foo.bar"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + testVal("mozilla.org"); + + testVal("mozilla.org<:666/file.ext>"); + testVal("mozilla.org<:666/file.ext>"); + testVal("localhost<:666/file.ext>"); + + let IPs = ["192.168.1.1", + "[::]", + "[::1]", + "[1::]", + "[::]", + "[::1]", + "[1::]", + "[1:2:3:4:5:6:7::]", + "[::1:2:3:4:5:6:7]", + "[1:2:a:B:c:D:e:F]", + "[1::8]", + "[1:2::8]", + "[fe80::222:19ff:fe11:8c76]", + "[0000:0123:4567:89AB:CDEF:abcd:ef00:0000]", + "[::192.168.1.1]", + "[1::0.0.0.0]", + "[1:2::255.255.255.255]", + "[1:2:3::255.255.255.255]", + "[1:2:3:4::255.255.255.255]", + "[1:2:3:4:5::255.255.255.255]", + "[1:2:3:4:5:6:255.255.255.255]"]; + IPs.forEach(function (IP) { + testVal(IP); + testVal(IP + ""); + testVal(IP + "<:666/file.ext>"); + testVal("" + IP); + testVal("" + IP + ""); + testVal("" + IP + "<:666/file.ext>"); + testVal("" + IP + "<:666/file.ext>"); + }); + + testVal("mailto:admin@mozilla.org"); + testVal("gopher://mozilla.org/"); + testVal("about:config"); + testVal("jar:http://mozilla.org/example.jar!/"); + testVal("view-source:http://mozilla.org/"); + testVal("foo9://mozilla.org/"); + testVal("foo+://mozilla.org/"); + testVal("foo.://mozilla.org/"); + testVal("foo-://mozilla.org/"); + + Services.prefs.setBoolPref(prefname, false); + + testVal("https://mozilla.org"); +} -- cgit v1.2.3