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