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