michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: const TESTCASE_URI = TEST_BASE + "four.html"; michael@0: michael@0: let gUI; michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: addTabAndOpenStyleEditors(4, runTests); michael@0: michael@0: content.location = TESTCASE_URI; michael@0: } michael@0: michael@0: function runTests(panel) michael@0: { michael@0: gUI = panel.UI; michael@0: gUI.editors[0].getSourceEditor().then(onEditor0Attach); michael@0: gUI.editors[2].getSourceEditor().then(onEditor2Attach); michael@0: } michael@0: michael@0: function getStylesheetNameLinkFor(aEditor) michael@0: { michael@0: return aEditor.summary.querySelector(".stylesheet-name"); michael@0: } michael@0: michael@0: function onEditor0Attach(aEditor) michael@0: { michael@0: waitForFocus(function () { michael@0: let summary = aEditor.summary; michael@0: EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow); michael@0: michael@0: let item = getStylesheetNameLinkFor(gUI.editors[0]); michael@0: is(gPanelWindow.document.activeElement, item, michael@0: "editor 0 item is the active element"); michael@0: michael@0: EventUtils.synthesizeKey("VK_DOWN", {}, gPanelWindow); michael@0: item = getStylesheetNameLinkFor(gUI.editors[1]); michael@0: is(gPanelWindow.document.activeElement, item, michael@0: "editor 1 item is the active element"); michael@0: michael@0: EventUtils.synthesizeKey("VK_HOME", {}, gPanelWindow); michael@0: item = getStylesheetNameLinkFor(gUI.editors[0]); michael@0: is(gPanelWindow.document.activeElement, item, michael@0: "fist editor item is the active element"); michael@0: michael@0: EventUtils.synthesizeKey("VK_END", {}, gPanelWindow); michael@0: item = getStylesheetNameLinkFor(gUI.editors[3]); michael@0: is(gPanelWindow.document.activeElement, item, michael@0: "last editor item is the active element"); michael@0: michael@0: EventUtils.synthesizeKey("VK_UP", {}, gPanelWindow); michael@0: item = getStylesheetNameLinkFor(gUI.editors[2]); michael@0: is(gPanelWindow.document.activeElement, item, michael@0: "editor 2 item is the active element"); michael@0: michael@0: EventUtils.synthesizeKey("VK_RETURN", {}, gPanelWindow); michael@0: // this will attach and give focus editor 2 michael@0: }, gPanelWindow); michael@0: } michael@0: michael@0: function onEditor2Attach(aEditor) michael@0: { michael@0: // Wait for the focus to be set. michael@0: executeSoon(function () { michael@0: ok(aEditor.sourceEditor.hasFocus(), michael@0: "editor 2 has focus"); michael@0: michael@0: gUI = null; michael@0: finish(); michael@0: }); michael@0: }