browser/devtools/styleeditor/test/browser_styleeditor_sv_keynav.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleeditor/test/browser_styleeditor_sv_keynav.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +/* vim: set ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +const TESTCASE_URI = TEST_BASE + "four.html";
     1.9 +
    1.10 +let gUI;
    1.11 +
    1.12 +function test()
    1.13 +{
    1.14 +  waitForExplicitFinish();
    1.15 +
    1.16 +  addTabAndOpenStyleEditors(4, runTests);
    1.17 +
    1.18 +  content.location = TESTCASE_URI;
    1.19 +}
    1.20 +
    1.21 +function runTests(panel)
    1.22 +{
    1.23 +  gUI = panel.UI;
    1.24 +  gUI.editors[0].getSourceEditor().then(onEditor0Attach);
    1.25 +  gUI.editors[2].getSourceEditor().then(onEditor2Attach);
    1.26 +}
    1.27 +
    1.28 +function getStylesheetNameLinkFor(aEditor)
    1.29 +{
    1.30 +  return aEditor.summary.querySelector(".stylesheet-name");
    1.31 +}
    1.32 +
    1.33 +function onEditor0Attach(aEditor)
    1.34 +{
    1.35 +  waitForFocus(function () {
    1.36 +    let summary = aEditor.summary;
    1.37 +    EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow);
    1.38 +
    1.39 +    let item = getStylesheetNameLinkFor(gUI.editors[0]);
    1.40 +    is(gPanelWindow.document.activeElement, item,
    1.41 +       "editor 0 item is the active element");
    1.42 +
    1.43 +    EventUtils.synthesizeKey("VK_DOWN", {}, gPanelWindow);
    1.44 +    item = getStylesheetNameLinkFor(gUI.editors[1]);
    1.45 +    is(gPanelWindow.document.activeElement, item,
    1.46 +       "editor 1 item is the active element");
    1.47 +
    1.48 +    EventUtils.synthesizeKey("VK_HOME", {}, gPanelWindow);
    1.49 +    item = getStylesheetNameLinkFor(gUI.editors[0]);
    1.50 +    is(gPanelWindow.document.activeElement, item,
    1.51 +       "fist editor item is the active element");
    1.52 +
    1.53 +    EventUtils.synthesizeKey("VK_END", {}, gPanelWindow);
    1.54 +    item = getStylesheetNameLinkFor(gUI.editors[3]);
    1.55 +    is(gPanelWindow.document.activeElement, item,
    1.56 +       "last editor item is the active element");
    1.57 +
    1.58 +    EventUtils.synthesizeKey("VK_UP", {}, gPanelWindow);
    1.59 +    item = getStylesheetNameLinkFor(gUI.editors[2]);
    1.60 +    is(gPanelWindow.document.activeElement, item,
    1.61 +       "editor 2 item is the active element");
    1.62 +
    1.63 +    EventUtils.synthesizeKey("VK_RETURN", {}, gPanelWindow);
    1.64 +    // this will attach and give focus editor 2
    1.65 +  }, gPanelWindow);
    1.66 +}
    1.67 +
    1.68 +function onEditor2Attach(aEditor)
    1.69 +{
    1.70 +  // Wait for the focus to be set.
    1.71 +  executeSoon(function () {
    1.72 +    ok(aEditor.sourceEditor.hasFocus(),
    1.73 +       "editor 2 has focus");
    1.74 +
    1.75 +    gUI = null;
    1.76 +    finish();
    1.77 +  });
    1.78 +}

mercurial