1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/inspector/test/browser_inspector_reload.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +/* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 + 1.11 +function test() { 1.12 + let inspector, toolbox; 1.13 + 1.14 + waitForExplicitFinish(); 1.15 + 1.16 + gBrowser.selectedTab = gBrowser.addTab(); 1.17 + gBrowser.selectedBrowser.addEventListener("load", function onload() { 1.18 + gBrowser.selectedBrowser.removeEventListener("load", onload, true); 1.19 + waitForFocus(function() { 1.20 + let target = TargetFactory.forTab(gBrowser.selectedTab); 1.21 + gDevTools.showToolbox(target, "inspector").then(function(toolbox) { 1.22 + startInspectorTests(toolbox); 1.23 + }).then(null, console.error); 1.24 + }, content); 1.25 + }, true); 1.26 + 1.27 + content.location = "data:text/html,<p>p</p>"; 1.28 + 1.29 + function startInspectorTests(aToolbox) 1.30 + { 1.31 + toolbox = aToolbox; 1.32 + inspector = toolbox.getCurrentPanel(); 1.33 + info("Inspector started"); 1.34 + let p = content.document.querySelector("p"); 1.35 + inspector.selection.setNode(p); 1.36 + inspector.once("inspector-updated", () => { 1.37 + is(inspector.selection.node, p, "Node selected."); 1.38 + inspector.once("markuploaded", onReload); 1.39 + content.location.reload(); 1.40 + }); 1.41 + } 1.42 + 1.43 + function onReload() { 1.44 + info("Page reloaded"); 1.45 + let p = content.document.querySelector("p"); 1.46 + inspector.selection.setNode(p); 1.47 + inspector.once("inspector-updated", () => { 1.48 + is(inspector.selection.node, p, "Node re-selected."); 1.49 + toolbox.destroy(); 1.50 + toolbox = inspector = null; 1.51 + gBrowser.removeCurrentTab(); 1.52 + finish(); 1.53 + }); 1.54 + } 1.55 +}