michael@0: /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: function test() { michael@0: let inspector, toolbox; 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: waitForFocus(function() { michael@0: let target = TargetFactory.forTab(gBrowser.selectedTab); michael@0: gDevTools.showToolbox(target, "inspector").then(function(toolbox) { michael@0: startInspectorTests(toolbox); michael@0: }).then(null, console.error); michael@0: }, content); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html,
p
"; michael@0: michael@0: function startInspectorTests(aToolbox) michael@0: { michael@0: toolbox = aToolbox; michael@0: inspector = toolbox.getCurrentPanel(); michael@0: info("Inspector started"); michael@0: let p = content.document.querySelector("p"); michael@0: inspector.selection.setNode(p); michael@0: inspector.once("inspector-updated", () => { michael@0: is(inspector.selection.node, p, "Node selected."); michael@0: inspector.once("markuploaded", onReload); michael@0: content.location.reload(); michael@0: }); michael@0: } michael@0: michael@0: function onReload() { michael@0: info("Page reloaded"); michael@0: let p = content.document.querySelector("p"); michael@0: inspector.selection.setNode(p); michael@0: inspector.once("inspector-updated", () => { michael@0: is(inspector.selection.node, p, "Node re-selected."); michael@0: toolbox.destroy(); michael@0: toolbox = inspector = null; michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }); michael@0: } michael@0: }