1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/inspector/test/browser_inspector_navigation.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 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 = "http://test1.example.org/browser/browser/devtools/inspector/test/browser_inspector_breadcrumbs.html"; 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 node = content.document.querySelector("#i1"); 1.35 + inspector.selection.setNode(node); 1.36 + inspector.once("inspector-updated", () => { 1.37 + is(inspector.selection.node, node, "Node selected."); 1.38 + inspector.once("markuploaded", onSecondLoad); 1.39 + content.location = "http://test2.example.org/browser/browser/devtools/inspector/test/browser_inspector_breadcrumbs.html"; 1.40 + }); 1.41 + } 1.42 + 1.43 + function onSecondLoad() { 1.44 + info("New page loaded"); 1.45 + let node = content.document.querySelector("#i1"); 1.46 + inspector.selection.setNode(node); 1.47 + 1.48 + inspector.once("inspector-updated", () => { 1.49 + is(inspector.selection.node, node, "Node re-selected."); 1.50 + inspector.once("markuploaded", onThirdLoad); 1.51 + content.history.go(-1); 1.52 + }); 1.53 + } 1.54 + 1.55 + function onThirdLoad() { 1.56 + info("Old page loaded"); 1.57 + is(content.location.href, "http://test1.example.org/browser/browser/devtools/inspector/test/browser_inspector_breadcrumbs.html"); 1.58 + let node = content.document.querySelector("#i1"); 1.59 + inspector.selection.setNode(node); 1.60 + inspector.once("inspector-updated", () => { 1.61 + is(inspector.selection.node, node, "Node re-selected."); 1.62 + inspector.once("markuploaded", onThirdLoad); 1.63 + toolbox.destroy(); 1.64 + gBrowser.removeCurrentTab(); 1.65 + finish(); 1.66 + }); 1.67 + } 1.68 +} 1.69 + 1.70 +