browser/base/content/test/general/browser_bug556061.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 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
     6 let testActionURL = "moz-action:switchtab," + testURL;
     7 testURL = gURLBar.trimValue(testURL);
     8 let testTab;
    10 function runNextTest() {
    11   if (tests.length) {
    12     let t = tests.shift();
    13     waitForClipboard(t.expected, t.setup, function() {
    14       t.success();
    15       runNextTest();
    16     }, cleanup);
    17   }
    18   else {
    19     cleanup();
    20   }
    21 }
    23 function cleanup() {
    24   gBrowser.removeTab(testTab);
    25   finish();
    26 }
    28 let tests = [
    29   {
    30     expected: testURL,
    31     setup: function() {
    32       gURLBar.value = testActionURL;
    33       gURLBar.valueIsTyped = true;
    34       is(gURLBar.value, testActionURL, "gURLBar.value starts with correct value");
    36       // Focus the urlbar so we can select it all & copy
    37       gURLBar.focus();
    38       gURLBar.select();
    39       goDoCommand("cmd_copy");
    40     },
    41     success: function() {
    42       is(gURLBar.value, testActionURL, "gURLBar.value didn't change when copying");
    43     }
    44   },
    45   {
    46     expected: testURL.substring(0, 10),
    47     setup: function() {
    48       // Set selectionStart/End manually and make sure it matches the substring
    49       gURLBar.selectionStart = 0;
    50       gURLBar.selectionEnd = 10;
    51       goDoCommand("cmd_copy");
    52     },
    53     success: function() {
    54       is(gURLBar.value, testActionURL, "gURLBar.value didn't change when copying");
    55     }
    56   },
    57   {
    58     expected: testURL,
    59     setup: function() {
    60       // Setup for cut test...
    61       // Select all
    62       gURLBar.select();
    63       goDoCommand("cmd_cut");
    64     },
    65     success: function() {
    66       is(gURLBar.value, "", "gURLBar.value is now empty");
    67     }
    68   },
    69   {
    70     expected: testURL.substring(testURL.length - 10, testURL.length),
    71     setup: function() {
    72       // Reset urlbar value
    73       gURLBar.value = testActionURL;
    74       gURLBar.valueIsTyped = true;
    75       // Sanity check that we have the right value
    76       is(gURLBar.value, testActionURL, "gURLBar.value starts with correct value");
    78       // Now just select part of the value & cut that.
    79       gURLBar.selectionStart = testURL.length - 10;
    80       gURLBar.selectionEnd = testURL.length;
    81       goDoCommand("cmd_cut");
    82     },
    83     success: function() {
    84       is(gURLBar.value, testURL.substring(0, testURL.length - 10), "gURLBar.value has the correct value");
    85     }
    86   }
    87 ];
    89 function test() {
    90   waitForExplicitFinish();
    91   testTab = gBrowser.addTab();
    92   gBrowser.selectedTab = testTab;
    94   // Kick off the testing
    95   runNextTest();
    96 }

mercurial