Wed, 31 Dec 2014 06:09:35 +0100
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_HTTPS + "simple.html";
6 const NEW_URI = TEST_BASE_HTTPS + "media.html";
8 const LINE_NO = 5;
9 const COL_NO = 3;
11 let gContentWin;
12 let gUI;
14 function test()
15 {
16 waitForExplicitFinish();
18 addTabAndOpenStyleEditors(2, function(panel) {
19 gContentWin = gBrowser.selectedTab.linkedBrowser.contentWindow.wrappedJSObject;
20 gUI = panel.UI;
21 gUI.editors[0].getSourceEditor().then(runTests);
22 });
24 content.location = TESTCASE_URI;
25 }
27 function runTests()
28 {
29 let count = 0;
30 gUI.once("editor-selected", (event, editor) => {
31 editor.getSourceEditor().then(() => {
32 info("selected second editor, about to reload page");
33 reloadPage();
35 gUI.on("editor-added", function editorAdded(event, editor) {
36 if (++count == 2) {
37 info("all editors added after reload");
38 gUI.off("editor-added", editorAdded);
39 gUI.editors[1].getSourceEditor().then(testRemembered);
40 }
41 })
42 });
43 });
44 gUI.selectStyleSheet(gUI.editors[1].styleSheet.href, LINE_NO, COL_NO);
45 }
47 function testRemembered()
48 {
49 is(gUI.selectedEditor, gUI.editors[1], "second editor is selected");
51 let {line, ch} = gUI.selectedEditor.sourceEditor.getCursor();
52 is(line, LINE_NO, "correct line selected");
53 is(ch, COL_NO, "correct column selected");
55 testNewPage();
56 }
58 function testNewPage()
59 {
60 let count = 0;
61 gUI.on("editor-added", function editorAdded(event, editor) {
62 info("editor added here")
63 if (++count == 2) {
64 info("all editors added after navigating page");
65 gUI.off("editor-added", editorAdded);
66 gUI.editors[0].getSourceEditor().then(testNotRemembered);
67 }
68 })
70 info("navigating to a different page");
71 navigatePage();
72 }
74 function testNotRemembered()
75 {
76 is(gUI.selectedEditor, gUI.editors[0], "first editor is selected");
78 let {line, ch} = gUI.selectedEditor.sourceEditor.getCursor();
79 is(line, 0, "first line is selected");
80 is(ch, 0, "first column is selected");
82 gUI = null;
83 finish();
84 }
86 function reloadPage()
87 {
88 gContentWin.location.reload();
89 }
91 function navigatePage()
92 {
93 gContentWin.location = NEW_URI;
94 }