2 <script src="jsdifflib.js"></script>
3 <script src="utilities.js"></script>
4 <script src="DOMExtension.js"></script>
5 <script src="treeoutline.js"></script>
7 <link rel="stylesheet" type="text/css" href="inspector.css">
31 var layoutTestsServer = "http://localhost:8002/";
32 var scannerServer = "http://localhost:8002/";
33 var remoteDebuggingServer = "http://localhost:9222/";
38 "inspector/console/console-api-on-call-frame.html",
41 "inspector/console/console-dir-global.html",
42 "inspector/console/console-log-toString-object.html",
43 "inspector/console/console-uncaught-exception-in-eval.html",
44 "inspector/elements/edit-dom-actions.html",
45 "inspector/elements/highlight-node-scaled.html",
46 "inspector/elements/highlight-node-scroll.html",
47 "inspector/elements/highlight-node.html",
48 "inspector/elements/highlight-svg-root.html",
49 "inspector/network-status-non-http.html",
50 "inspector/storage-panel-dom-storage-update.html",
51 "inspector/styles/inject-stylesheet.html",
52 "inspector/styles/protocol-css-regions-commands.html",
53 "inspector/styles/region-style-crash.html",
54 "inspector/styles/styles-disable-then-enable-overriden-ua.html",
55 "inspector/styles/styles-url-linkify.html",
56 "inspector/styles/vendor-prefixes.html",
57 "inspector/timeline/timeline-event-dispatch.html",
58 "inspector/timeline/timeline-frames.html",
59 "inspector/timeline/timeline-network-resource.html",
60 "inspector/timeline/timeline-paint.html",
61 "inspector/timeline/timeline-receive-response-event.html",
64 "inspector/profiler/cpu-profiler-profiling-without-inspector.html",
65 "inspector/profiler/heap-snapshot-inspect-dom-wrapper.html",
66 "inspector/timeline/timeline-network-received-data.html",
68 var treeOutline = null;
72 if (window.runner && debug) {
73 window.runner.continueDebugging();
77 if (window.testScannerIframe)
78 document.body.removeChild(window.testScannerIframe);
81 window.runner.cleanup();
83 window.testScannerIframe = document.createElement("iframe");
84 window.testScannerIframe.src = scannerServer + "LayoutTests/http/tests/inspector/resources/test-scanner.html";
85 document.body.appendChild(window.testScannerIframe);
91 document.getElementById("outline").removeChildren();
92 treeOutline = new TreeOutline(document.getElementById("outline"));
94 document.getElementById("pass").textContent = 0;
95 document.getElementById("skip").textContent = 0;
96 document.getElementById("fail").textContent = 0;
97 document.getElementById("timeout").textContent = 0;
98 document.getElementById("remaining").textContent = tests.length;
108 function runNextTest(lastResult)
111 var element = document.getElementById(lastResult);
112 element.textContent = parseInt(element.textContent) + 1;
114 element = document.getElementById("remaining");
115 element.textContent = parseInt(element.textContent) - 1;
117 document.getElementById("debug").textContent = "Debug";
123 var filter = document.getElementById("filter").value;
124 while (test = tests.shift()) {
125 if (!filter || test[0].match(filter)) {
126 new StandaloneTestRunner(layoutTestsServer + test[0], test[1], runNextTest.bind(null));
132 function StandaloneTestRunner(testPath, expected, next)
134 this._testPath = testPath;
136 this._expected = expected;
137 this._pendingMessages = [];
139 this._treeElement = new TreeElement(testPath);
140 treeOutline.appendChild(this._treeElement);
142 for (var i = 0; !window.debug && i < skipList.length; ++i) {
143 if (testPath.indexOf(skipList[i]) !== -1) {
144 this._treeElement.title = testPath + ": SKIPPED";
149 window.runner = this;
150 this._testPage = window.open("about:blank", "inspected", "width=800,height=600");
152 window.remoteDebuggingHandshake = this._remoteDebuggingHandshake.bind(this);
153 var script = document.createElement("script");
154 script.src = remoteDebuggingServer + "json?jsonp=remoteDebuggingHandshake";
155 document.head.appendChild(script);
158 StandaloneTestRunner.FrontendLocation = "inspector.html";
160 StandaloneTestRunner.prototype = {
161 _remoteDebuggingHandshake: function(data)
163 for (var i = 0; i < data.length; ++i) {
164 if (data[i].url !== "about:blank")
166 this._debuggerURL = data[i].webSocketDebuggerUrl.replace("://", "=");
167 this._navigateTestPage();
172 _navigateTestPage: function()
174 this._testPage.location.href = this._testPath;
175 var width = localStorage.getItem('inspectorWidth') || 600;
176 var height = localStorage.getItem('inspectorHeight') || 400;
177 var features = "width=" + Math.max(width , 600) + ",height=" + Math.max(height, 400);
178 this._inspectorWindowLoading = window.open(StandaloneTestRunner.FrontendLocation + "?" + this._debuggerURL, "inspector", features);
179 this._inspectorWindowLoading.dispatchStandaloneTestRunnerMessages = true;
181 window.addEventListener('unload', this.cleanup.bind(this));
184 this._watchDog = setTimeout(this._timeout.bind(this), 10000);
187 loadCompleted: function()
190 this._loadCompleted(this);
193 document.getElementById("debug").textContent = "Continue";
196 continueDebugging: function()
198 this._loadCompleted();
201 _loadCompleted: function()
203 this._inspectorWindow = this._inspectorWindowLoading;
204 for (var i = 0; i < this._pendingMessages.length; ++i)
205 this._inspectorWindow.postMessage(this._pendingMessages[i], "*");
206 this._pendingMessages = [];
209 closeWebInspector: function()
212 this._inspectorWindow.close();
215 notifyDone: function(actual)
224 clearTimeout(this._watchDog);
226 this._treeElement.onselect = this.onTreeElementSelect.bind(this);
228 // TODO pavel is the RHS || condition wanted?
229 if (actual === this._expected || actual === this._expected + "\n") {
230 this._treeElement.title = this._testPath + ": SUCCESS";
235 this._treeElement.title = this._testPath + ": FAILED";
236 this._treeElement.listItemElement.classList.add("failed");
238 var baseLines = difflib.stringAsLines(this._expected);
239 var newLines = difflib.stringAsLines(actual);
240 var sm = new difflib.SequenceMatcher(baseLines, newLines);
241 var opcodes = sm.get_opcodes();
242 var lastWasSeparator = false;
244 for (var idx = 0; idx < opcodes.length; idx++) {
245 var code = opcodes[idx];
246 var change = code[0];
251 var rowCount = Math.max(be - b, ne - n);
254 for (var i = 0; i < rowCount; i++) {
255 if (change === "delete" || (change === "replace" && b < be)) {
256 var lineNumber = b++;
257 this._treeElement.appendChild(new TreeElement("- [" + lineNumber + "] " + baseLines[lineNumber]));
260 if (change === "insert" || (change === "replace" && n < ne)) {
261 var lineNumber = n++;
262 this._treeElement.appendChild(new TreeElement("+ [" + lineNumber + "] " + newLines[lineNumber]));
265 if (change === "equal") {
275 evaluateInWebInspector: function(callId, script)
277 if (this._inspectorWindow)
278 this._inspectorWindow.postMessage(["evaluateForTest", callId, script], "*");
280 this._pendingMessages.push(["evaluateForTest", callId, script]);
285 this._treeElement.title = this._testPath + ": TIMEOUT";
286 this._treeElement.listItemElement.classList.add("timeout");
289 this._next("timeout");
294 localStorage.setItem('inspectorWidth', this._inspectorWindowLoading.outerWidth);
295 localStorage.setItem('inspectorHeight', this._inspectorWindowLoading.outerHeight);
296 this._inspectorWindowLoading.close();
297 this._testPage.close();
298 delete window.runner;
301 onTreeElementSelect: function ()
303 var baseEndSentinel = '/inspector/';
304 var baseChars = this._testPath.indexOf(baseEndSentinel) + baseEndSentinel.length;
306 document.getElementById("filter").value = this._testPath.substr(baseChars);
309 display: function() { }
312 function onMessageFromTestPage(event)
314 var signature = event.data;
315 var method = signature.shift();
316 if (method === "tests") {
317 tests = signature[0];
323 window.runner[method].apply(window.runner, signature);
328 var queryParamsObject = {};
329 var queryParams = window.location.search;
332 var params = queryParams.substring(1).split("&");
333 for (var i = 0; i < params.length; ++i) {
334 var pair = params[i].split("=");
335 queryParamsObject[pair[0]] = pair[1];
337 if ("filter" in queryParamsObject)
338 document.getElementById("filter").value = queryParamsObject["filter"];
341 window.addEventListener("message", onMessageFromTestPage, true);
344 <body onload="onload()">
345 This is a standalone test suite for inspector front-end. Here is how you run it:
347 <li>Check out WebKit source tree: git clone http://git.chromium.org/external/Webkit.git</li>
348 <li>Run "Tools/Scripts/new-run-webkit-httpd --root=. --port=8002 --server=start"</li>
349 <li>Run Chrome Canary (ToT Chromium) with following flags: "--remote-debugging-port=9222 --user-data-dir=testProfile http://localhost:8002/Source/devtools/front_end/test-runner.html"</li>
352 <button onclick="run()">Run</button>
353 <button id="debug" onclick="run(true)">Debug</button>
354 <button onclick="interrupt()">Interrupt</button>
355 Filter: <input id="filter" type="text" size="40"></input><small><i>Click on results to load filter</i></small><br>
357 <span>Passed: <span id="pass">0</span></span>
358 <span>Failed: <span id="fail">0</span></span>
359 <span>Timeout: <span id="timeout">0</span></span>
360 <span>Skipped: <span id="skip">0</span></span>
361 <span>Remaining: <span id="remaining">0</span><br>
363 <ol id="outline" style="font-size: 12px !important" class="source-code outline-disclosure"></ol>