browser/base/content/test/general/browser_urlbarTrimURLs.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 function testVal(originalValue, targetValue) {
     6   gURLBar.value = originalValue;
     7   gURLBar.valueIsTyped = false;
     8   is(gURLBar.value, targetValue || originalValue, "url bar value set");
     9 }
    11 function test() {
    12   const prefname = "browser.urlbar.trimURLs";
    14   gBrowser.selectedTab = gBrowser.addTab();
    16   registerCleanupFunction(function () {
    17     gBrowser.removeCurrentTab();
    18     Services.prefs.clearUserPref(prefname);
    19     URLBarSetURI();
    20   });
    22   Services.prefs.setBoolPref(prefname, true);
    24   testVal("http://mozilla.org/", "mozilla.org");
    25   testVal("https://mozilla.org/", "https://mozilla.org");
    26   testVal("http://mözilla.org/", "mözilla.org");
    27   testVal("http://mozilla.imaginatory/", "mozilla.imaginatory");
    28   testVal("http://www.mozilla.org/", "www.mozilla.org");
    29   testVal("http://sub.mozilla.org/", "sub.mozilla.org");
    30   testVal("http://sub1.sub2.sub3.mozilla.org/", "sub1.sub2.sub3.mozilla.org");
    31   testVal("http://mozilla.org/file.ext", "mozilla.org/file.ext");
    32   testVal("http://mozilla.org/sub/", "mozilla.org/sub/");
    34   testVal("http://ftp.mozilla.org/", "http://ftp.mozilla.org");
    35   testVal("http://ftp1.mozilla.org/", "http://ftp1.mozilla.org");
    36   testVal("http://ftp42.mozilla.org/", "http://ftp42.mozilla.org");
    37   testVal("http://ftpx.mozilla.org/", "ftpx.mozilla.org");
    38   testVal("ftp://ftp.mozilla.org/", "ftp://ftp.mozilla.org");
    39   testVal("ftp://ftp1.mozilla.org/", "ftp://ftp1.mozilla.org");
    40   testVal("ftp://ftp42.mozilla.org/", "ftp://ftp42.mozilla.org");
    41   testVal("ftp://ftpx.mozilla.org/", "ftp://ftpx.mozilla.org");
    43   testVal("https://user:pass@mozilla.org/", "https://user:pass@mozilla.org");
    44   testVal("http://user:pass@mozilla.org/", "http://user:pass@mozilla.org");
    45   testVal("http://sub.mozilla.org:666/", "sub.mozilla.org:666");
    47   testVal("https://[fe80::222:19ff:fe11:8c76]/file.ext");
    48   testVal("http://[fe80::222:19ff:fe11:8c76]/", "[fe80::222:19ff:fe11:8c76]");
    49   testVal("https://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext");
    50   testVal("http://user:pass@[fe80::222:19ff:fe11:8c76]:666/file.ext");
    52   testVal("mailto:admin@mozilla.org");
    53   testVal("gopher://mozilla.org/");
    54   testVal("about:config");
    55   testVal("jar:http://mozilla.org/example.jar!/");
    56   testVal("view-source:http://mozilla.org/");
    58   Services.prefs.setBoolPref(prefname, false);
    60   testVal("http://mozilla.org/");
    62   Services.prefs.setBoolPref(prefname, true);
    64   waitForExplicitFinish();
    66   gBrowser.selectedBrowser.addEventListener("load", function () {
    67     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
    69     is(gBrowser.currentURI.spec, "http://example.com/", "expected page should have loaded");
    71     testCopy("example.com", "http://example.com/", function () {
    72       SetPageProxyState("invalid");
    73       gURLBar.valueIsTyped = true;
    74       testCopy("example.com", "example.com", finish);
    75     });
    76   }, true);
    78   gBrowser.loadURI("http://example.com/");
    79 }
    81 function testCopy(originalValue, targetValue, cb) {
    82   waitForClipboard(targetValue, function () {
    83     is(gURLBar.value, originalValue, "url bar copy value set");
    85     gURLBar.focus();
    86     gURLBar.select();
    87     goDoCommand("cmd_copy");
    88   }, cb, cb);
    89 }

mercurial