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.

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

mercurial