browser/devtools/styleeditor/test/browser_styleeditor_sv_keynav.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 /* vim: set ts=2 et sw=2 tw=80: */
     2 /* Any copyright is dedicated to the Public Domain.
     3    http://creativecommons.org/publicdomain/zero/1.0/ */
     5 const TESTCASE_URI = TEST_BASE + "four.html";
     7 let gUI;
     9 function test()
    10 {
    11   waitForExplicitFinish();
    13   addTabAndOpenStyleEditors(4, runTests);
    15   content.location = TESTCASE_URI;
    16 }
    18 function runTests(panel)
    19 {
    20   gUI = panel.UI;
    21   gUI.editors[0].getSourceEditor().then(onEditor0Attach);
    22   gUI.editors[2].getSourceEditor().then(onEditor2Attach);
    23 }
    25 function getStylesheetNameLinkFor(aEditor)
    26 {
    27   return aEditor.summary.querySelector(".stylesheet-name");
    28 }
    30 function onEditor0Attach(aEditor)
    31 {
    32   waitForFocus(function () {
    33     let summary = aEditor.summary;
    34     EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow);
    36     let item = getStylesheetNameLinkFor(gUI.editors[0]);
    37     is(gPanelWindow.document.activeElement, item,
    38        "editor 0 item is the active element");
    40     EventUtils.synthesizeKey("VK_DOWN", {}, gPanelWindow);
    41     item = getStylesheetNameLinkFor(gUI.editors[1]);
    42     is(gPanelWindow.document.activeElement, item,
    43        "editor 1 item is the active element");
    45     EventUtils.synthesizeKey("VK_HOME", {}, gPanelWindow);
    46     item = getStylesheetNameLinkFor(gUI.editors[0]);
    47     is(gPanelWindow.document.activeElement, item,
    48        "fist editor item is the active element");
    50     EventUtils.synthesizeKey("VK_END", {}, gPanelWindow);
    51     item = getStylesheetNameLinkFor(gUI.editors[3]);
    52     is(gPanelWindow.document.activeElement, item,
    53        "last editor item is the active element");
    55     EventUtils.synthesizeKey("VK_UP", {}, gPanelWindow);
    56     item = getStylesheetNameLinkFor(gUI.editors[2]);
    57     is(gPanelWindow.document.activeElement, item,
    58        "editor 2 item is the active element");
    60     EventUtils.synthesizeKey("VK_RETURN", {}, gPanelWindow);
    61     // this will attach and give focus editor 2
    62   }, gPanelWindow);
    63 }
    65 function onEditor2Attach(aEditor)
    66 {
    67   // Wait for the focus to be set.
    68   executeSoon(function () {
    69     ok(aEditor.sourceEditor.hasFocus(),
    70        "editor 2 has focus");
    72     gUI = null;
    73     finish();
    74   });
    75 }

mercurial