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 | function test() |
michael@0 | 6 | { |
michael@0 | 7 | waitForExplicitFinish(); |
michael@0 | 8 | |
michael@0 | 9 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 10 | gBrowser.selectedBrowser.addEventListener("load", function onLoad() { |
michael@0 | 11 | gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); |
michael@0 | 12 | openScratchpad(runTests); |
michael@0 | 13 | }, true); |
michael@0 | 14 | |
michael@0 | 15 | content.location = "data:text/html,<title>foobarBug636725</title>" + |
michael@0 | 16 | "<p>test inspect() in Scratchpad"; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function runTests() |
michael@0 | 20 | { |
michael@0 | 21 | let sp = gScratchpadWindow.Scratchpad; |
michael@0 | 22 | let doc = gScratchpadWindow.document; |
michael@0 | 23 | |
michael@0 | 24 | let methodsAndItems = { |
michael@0 | 25 | "sp-menu-newscratchpad": "openScratchpad", |
michael@0 | 26 | "sp-menu-open": "openFile", |
michael@0 | 27 | "sp-menu-save": "saveFile", |
michael@0 | 28 | "sp-menu-saveas": "saveFileAs", |
michael@0 | 29 | "sp-text-run": "run", |
michael@0 | 30 | "sp-text-inspect": "inspect", |
michael@0 | 31 | "sp-text-display": "display", |
michael@0 | 32 | "sp-text-reloadAndRun": "reloadAndRun", |
michael@0 | 33 | "sp-menu-content": "setContentContext", |
michael@0 | 34 | "sp-menu-browser": "setBrowserContext", |
michael@0 | 35 | "sp-menu-pprint": "prettyPrint", |
michael@0 | 36 | "sp-menu-line-numbers": "toggleEditorOption", |
michael@0 | 37 | "sp-menu-word-wrap": "toggleEditorOption", |
michael@0 | 38 | "sp-menu-highlight-trailing-space": "toggleEditorOption", |
michael@0 | 39 | "sp-menu-larger-font": "increaseFontSize", |
michael@0 | 40 | "sp-menu-smaller-font": "decreaseFontSize", |
michael@0 | 41 | "sp-menu-normal-size-font": "normalFontSize", |
michael@0 | 42 | }; |
michael@0 | 43 | |
michael@0 | 44 | let lastMethodCalled = null; |
michael@0 | 45 | |
michael@0 | 46 | for (let id in methodsAndItems) { |
michael@0 | 47 | lastMethodCalled = null; |
michael@0 | 48 | |
michael@0 | 49 | let methodName = methodsAndItems[id]; |
michael@0 | 50 | let oldMethod = sp[methodName]; |
michael@0 | 51 | ok(oldMethod, "found method " + methodName + " in Scratchpad object"); |
michael@0 | 52 | |
michael@0 | 53 | sp[methodName] = () => { |
michael@0 | 54 | lastMethodCalled = methodName; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | let menu = doc.getElementById(id); |
michael@0 | 58 | ok(menu, "found menuitem #" + id); |
michael@0 | 59 | |
michael@0 | 60 | try { |
michael@0 | 61 | menu.doCommand(); |
michael@0 | 62 | } |
michael@0 | 63 | catch (ex) { |
michael@0 | 64 | ok(false, "exception thrown while executing the command of menuitem #" + id); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | ok(lastMethodCalled == methodName, |
michael@0 | 68 | "method " + methodName + " invoked by the associated menuitem"); |
michael@0 | 69 | |
michael@0 | 70 | sp[methodName] = oldMethod; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | finish(); |
michael@0 | 74 | } |