1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/mochitest/test_inspector-insert.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,96 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id= 1.8 +--> 1.9 +<head> 1.10 + <meta charset="utf-8"> 1.11 + <title>Test for Bug </title> 1.12 + 1.13 + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> 1.15 + <script type="application/javascript;version=1.8" src="inspector-helpers.js"></script> 1.16 + <script type="application/javascript;version=1.8"> 1.17 +Components.utils.import("resource://gre/modules/devtools/Loader.jsm"); 1.18 +const {Promise: promise} = Components.utils.import("resource://gre/modules/Promise.jsm", {}); 1.19 + 1.20 +const inspector = devtools.require("devtools/server/actors/inspector"); 1.21 + 1.22 +window.onload = function() { 1.23 + SimpleTest.waitForExplicitFinish(); 1.24 + runNextTest(); 1.25 +} 1.26 + 1.27 +var gWalker = null; 1.28 +var gClient = null; 1.29 + 1.30 +function assertOwnership() { 1.31 + return assertOwnershipTrees(gWalker); 1.32 +} 1.33 + 1.34 +addTest(function setup() { 1.35 + let url = document.getElementById("inspectorContent").href; 1.36 + attachURL(url, function(err, client, tab, doc) { 1.37 + gInspectee = doc; 1.38 + let {InspectorFront} = devtools.require("devtools/server/actors/inspector"); 1.39 + let inspector = InspectorFront(client, tab); 1.40 + promiseDone(inspector.getWalker().then(walker => { 1.41 + ok(walker, "getWalker() should return an actor."); 1.42 + gClient = client; 1.43 + gWalker = walker; 1.44 + }).then(runNextTest)); 1.45 + }); 1.46 +}); 1.47 + 1.48 +addTest(function testRearrange() { 1.49 + let longlist = null; 1.50 + let nodeA = null; 1.51 + let nextNode = null; 1.52 + 1.53 + promiseDone(gWalker.querySelector(gWalker.rootNode, "#longlist").then(listFront => { 1.54 + longlist = listFront; 1.55 + }).then(() => { 1.56 + return gWalker.children(longlist); 1.57 + }).then(response => { 1.58 + nodeA = response.nodes[0]; 1.59 + is(nodeA.id, "a", "Got the expected node."); 1.60 + // Move nodeA to the end of the list. 1.61 + return gWalker.insertBefore(nodeA, longlist, null); 1.62 + }).then(() => { 1.63 + ok(!gInspectee.querySelector("#a").nextSibling, "a should now be at the end of the list."); 1.64 + return gWalker.children(longlist); 1.65 + }).then(response => { 1.66 + is(nodeA, response.nodes[response.nodes.length - 1], "a should now be the last returned child."); 1.67 + // Now move it to the middle of the list. 1.68 + nextNode = response.nodes[13]; 1.69 + return gWalker.insertBefore(nodeA, longlist, nextNode); 1.70 + }).then(response => { 1.71 + let sibling = inspector._documentWalker(gInspectee.querySelector("#a"), window).nextSibling(); 1.72 + is(sibling, nextNode.rawNode(), "Node should match the expected next node."); 1.73 + return gWalker.children(longlist); 1.74 + }).then(response => { 1.75 + is(nodeA, response.nodes[13], "a should be where we expect it."); 1.76 + is(nextNode, response.nodes[14], "next node should be where we expect it."); 1.77 + }).then(runNextTest)); 1.78 +}); 1.79 + 1.80 +addTest(function cleanup() { 1.81 + delete gWalker; 1.82 + delete gClient; 1.83 + runNextTest(); 1.84 +}); 1.85 + 1.86 + 1.87 + </script> 1.88 +</head> 1.89 +<body> 1.90 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> 1.91 +<a id="inspectorContent" target="_blank" href="inspector-traversal-data.html">Test Document</a> 1.92 +<p id="display"></p> 1.93 +<div id="content" style="display: none"> 1.94 + 1.95 +</div> 1.96 +<pre id="test"> 1.97 +</pre> 1.98 +</body> 1.99 +</html>