mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bf8e5ab9a8
--HG-- rename : browser/devtools/framework/Sidebar.jsm => browser/devtools/framework/sidebar.js rename : browser/devtools/framework/Target.jsm => browser/devtools/framework/target.js rename : browser/devtools/framework/ToolboxHosts.jsm => browser/devtools/framework/toolbox-hosts.js rename : browser/devtools/framework/Toolbox.jsm => browser/devtools/framework/toolbox.js rename : browser/devtools/inspector/Breadcrumbs.jsm => browser/devtools/inspector/breadcrumbs.js rename : browser/devtools/inspector/Highlighter.jsm => browser/devtools/inspector/highlighter.js rename : browser/devtools/inspector/InspectorPanel.jsm => browser/devtools/inspector/inspector-panel.js rename : browser/devtools/inspector/Selection.jsm => browser/devtools/inspector/selection.js rename : browser/devtools/inspector/SelectorSearch.jsm => browser/devtools/inspector/selector-search.js rename : browser/devtools/framework/ToolDefinitions.jsm => browser/devtools/main.js rename : browser/devtools/markupview/MarkupView.jsm => browser/devtools/markupview/markup-view.js rename : browser/devtools/shared/EventEmitter.jsm => browser/devtools/shared/event-emitter.js rename : browser/devtools/shared/InplaceEditor.jsm => browser/devtools/shared/inplace-editor.js rename : browser/devtools/shared/Undo.jsm => browser/devtools/shared/undo.js rename : browser/devtools/styleinspector/CssHtmlTree.jsm => browser/devtools/styleinspector/computed-view.js rename : browser/devtools/styleinspector/CssLogic.jsm => browser/devtools/styleinspector/css-logic.js rename : browser/devtools/styleinspector/CssRuleView.jsm => browser/devtools/styleinspector/rule-view.js rename : browser/devtools/styleinspector/StyleInspector.jsm => browser/devtools/styleinspector/style-inspector.js rename : browser/devtools/tilt/TiltGL.jsm => browser/devtools/tilt/tilt-gl.js rename : browser/devtools/tilt/TiltMath.jsm => browser/devtools/tilt/tilt-math.js rename : browser/devtools/tilt/TiltUtils.jsm => browser/devtools/tilt/tilt-utils.js rename : browser/devtools/tilt/TiltVisualizerStyle.jsm => browser/devtools/tilt/tilt-visualizer-style.js rename : browser/devtools/tilt/TiltVisualizer.jsm => browser/devtools/tilt/tilt-visualizer.js rename : browser/devtools/tilt/Tilt.jsm => browser/devtools/tilt/tilt.js
108 lines
3.0 KiB
JavaScript
108 lines
3.0 KiB
JavaScript
/* vim: set ts=2 et sw=2 tw=80: */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
let toolbox;
|
|
|
|
function test()
|
|
{
|
|
waitForExplicitFinish();
|
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
|
|
|
gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
|
|
gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
|
|
gDevTools.showToolbox(target).then(testRegister);
|
|
}, true);
|
|
|
|
content.location = "data:text/html,test for dynamically registering and unregistering tools";
|
|
}
|
|
|
|
function testRegister(aToolbox)
|
|
{
|
|
toolbox = aToolbox
|
|
gDevTools.once("tool-registered", toolRegistered);
|
|
|
|
gDevTools.registerTool({
|
|
id: "test-tool",
|
|
label: "Test Tool",
|
|
isTargetSupported: function() true,
|
|
build: function() {}
|
|
});
|
|
}
|
|
|
|
function toolRegistered(event, toolId)
|
|
{
|
|
is(toolId, "test-tool", "tool-registered event handler sent tool id");
|
|
|
|
ok(gDevTools.getToolDefinitionMap().has(toolId), "tool added to map");
|
|
|
|
// test that it appeared in the UI
|
|
let doc = toolbox.frame.contentDocument;
|
|
let tab = doc.getElementById("toolbox-tab-" + toolId);
|
|
ok(tab, "new tool's tab exists in toolbox UI");
|
|
|
|
let panel = doc.getElementById("toolbox-panel-" + toolId);
|
|
ok(panel, "new tool's panel exists in toolbox UI");
|
|
|
|
for (let win of getAllBrowserWindows()) {
|
|
let command = win.document.getElementById("Tools:" + toolId);
|
|
ok(command, "command for new tool added to every browser window");
|
|
let menuitem = win.document.getElementById("menuitem_" + toolId);
|
|
ok(menuitem, "menu item of new tool added to every browser window");
|
|
}
|
|
|
|
// then unregister it
|
|
testUnregister();
|
|
}
|
|
|
|
function getAllBrowserWindows() {
|
|
let wins = [];
|
|
let enumerator = Services.wm.getEnumerator("navigator:browser");
|
|
while (enumerator.hasMoreElements()) {
|
|
wins.push(enumerator.getNext());
|
|
}
|
|
return wins;
|
|
}
|
|
|
|
function testUnregister()
|
|
{
|
|
gDevTools.once("tool-unregistered", toolUnregistered);
|
|
|
|
gDevTools.unregisterTool("test-tool");
|
|
}
|
|
|
|
function toolUnregistered(event, toolDefinition)
|
|
{
|
|
let toolId = toolDefinition.id;
|
|
is(toolId, "test-tool", "tool-unregistered event handler sent tool id");
|
|
|
|
ok(!gDevTools.getToolDefinitionMap().has(toolId), "tool removed from map");
|
|
|
|
// test that it disappeared from the UI
|
|
let doc = toolbox.frame.contentDocument;
|
|
let tab = doc.getElementById("toolbox-tab-" + toolId);
|
|
ok(!tab, "tool's tab was removed from the toolbox UI");
|
|
|
|
let panel = doc.getElementById("toolbox-panel-" + toolId);
|
|
ok(!panel, "tool's panel was removed from toolbox UI");
|
|
|
|
for (let win of getAllBrowserWindows()) {
|
|
let command = win.document.getElementById("Tools:" + toolId);
|
|
ok(!command, "command removed from every browser window");
|
|
let menuitem = win.document.getElementById("menuitem_" + toolId);
|
|
ok(!menuitem, "menu item removed from every browser window");
|
|
}
|
|
|
|
cleanup();
|
|
}
|
|
|
|
function cleanup()
|
|
{
|
|
toolbox.destroy();
|
|
toolbox = null;
|
|
gBrowser.removeCurrentTab();
|
|
finish();
|
|
}
|