|
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/ */ |
|
4 |
|
5 const TESTCASE_URI = TEST_BASE + "four.html"; |
|
6 |
|
7 let gUI; |
|
8 |
|
9 function test() |
|
10 { |
|
11 waitForExplicitFinish(); |
|
12 |
|
13 addTabAndOpenStyleEditors(4, runTests); |
|
14 |
|
15 content.location = TESTCASE_URI; |
|
16 } |
|
17 |
|
18 function runTests(panel) |
|
19 { |
|
20 gUI = panel.UI; |
|
21 gUI.editors[0].getSourceEditor().then(onEditor0Attach); |
|
22 gUI.editors[2].getSourceEditor().then(onEditor2Attach); |
|
23 } |
|
24 |
|
25 function getStylesheetNameLinkFor(aEditor) |
|
26 { |
|
27 return aEditor.summary.querySelector(".stylesheet-name"); |
|
28 } |
|
29 |
|
30 function onEditor0Attach(aEditor) |
|
31 { |
|
32 waitForFocus(function () { |
|
33 let summary = aEditor.summary; |
|
34 EventUtils.synthesizeMouseAtCenter(summary, {}, gPanelWindow); |
|
35 |
|
36 let item = getStylesheetNameLinkFor(gUI.editors[0]); |
|
37 is(gPanelWindow.document.activeElement, item, |
|
38 "editor 0 item is the active element"); |
|
39 |
|
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"); |
|
44 |
|
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"); |
|
49 |
|
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"); |
|
54 |
|
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"); |
|
59 |
|
60 EventUtils.synthesizeKey("VK_RETURN", {}, gPanelWindow); |
|
61 // this will attach and give focus editor 2 |
|
62 }, gPanelWindow); |
|
63 } |
|
64 |
|
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"); |
|
71 |
|
72 gUI = null; |
|
73 finish(); |
|
74 }); |
|
75 } |