michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function onLoad() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); michael@0: openScratchpad(runTests); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html,foobarBug636725" + michael@0: "

test inspect() in Scratchpad"; michael@0: } michael@0: michael@0: function runTests() michael@0: { michael@0: let sp = gScratchpadWindow.Scratchpad; michael@0: let doc = gScratchpadWindow.document; michael@0: michael@0: let methodsAndItems = { michael@0: "sp-menu-newscratchpad": "openScratchpad", michael@0: "sp-menu-open": "openFile", michael@0: "sp-menu-save": "saveFile", michael@0: "sp-menu-saveas": "saveFileAs", michael@0: "sp-text-run": "run", michael@0: "sp-text-inspect": "inspect", michael@0: "sp-text-display": "display", michael@0: "sp-text-reloadAndRun": "reloadAndRun", michael@0: "sp-menu-content": "setContentContext", michael@0: "sp-menu-browser": "setBrowserContext", michael@0: "sp-menu-pprint": "prettyPrint", michael@0: "sp-menu-line-numbers": "toggleEditorOption", michael@0: "sp-menu-word-wrap": "toggleEditorOption", michael@0: "sp-menu-highlight-trailing-space": "toggleEditorOption", michael@0: "sp-menu-larger-font": "increaseFontSize", michael@0: "sp-menu-smaller-font": "decreaseFontSize", michael@0: "sp-menu-normal-size-font": "normalFontSize", michael@0: }; michael@0: michael@0: let lastMethodCalled = null; michael@0: michael@0: for (let id in methodsAndItems) { michael@0: lastMethodCalled = null; michael@0: michael@0: let methodName = methodsAndItems[id]; michael@0: let oldMethod = sp[methodName]; michael@0: ok(oldMethod, "found method " + methodName + " in Scratchpad object"); michael@0: michael@0: sp[methodName] = () => { michael@0: lastMethodCalled = methodName; michael@0: } michael@0: michael@0: let menu = doc.getElementById(id); michael@0: ok(menu, "found menuitem #" + id); michael@0: michael@0: try { michael@0: menu.doCommand(); michael@0: } michael@0: catch (ex) { michael@0: ok(false, "exception thrown while executing the command of menuitem #" + id); michael@0: } michael@0: michael@0: ok(lastMethodCalled == methodName, michael@0: "method " + methodName + " invoked by the associated menuitem"); michael@0: michael@0: sp[methodName] = oldMethod; michael@0: } michael@0: michael@0: finish(); michael@0: }