- Revision
- 125548
- Author
- pfeld...@chromium.org
- Date
- 2012-08-14 04:52:00 -0700 (Tue, 14 Aug 2012)
Log Message
Web Inspector: add external test runner for running inspector front-end tests with no TestRunner infrastructure.
https://bugs.webkit.org/show_bug.cgi?id=93833
Reviewed by Yury Semikhatsky.
Source/WebCore:
Added mock test runner that allows running front-end layout tests.
InspectorFrontendAPI can now dispatch whatever it receives from its embedder (opener).
* inspector/front-end/InspectorFrontendAPI.js:
(InspectorFrontendAPI.evaluateForTest):
(InspectorFrontendAPI.dispatch):
(InspectorFrontendAPI.loadCompleted):
(.onMessageFromOpener):
LayoutTests:
* http/tests/inspector/inspector-test.js:
* http/tests/inspector/resources/test-runner.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (125547 => 125548)
--- trunk/LayoutTests/ChangeLog 2012-08-14 11:47:30 UTC (rev 125547)
+++ trunk/LayoutTests/ChangeLog 2012-08-14 11:52:00 UTC (rev 125548)
@@ -1,3 +1,13 @@
+2012-08-14 Pavel Feldman <pfeld...@chromium.org>
+
+ Web Inspector: add external test runner for running inspector front-end tests with no TestRunner infrastructure.
+ https://bugs.webkit.org/show_bug.cgi?id=93833
+
+ Reviewed by Yury Semikhatsky.
+
+ * http/tests/inspector/inspector-test.js:
+ * http/tests/inspector/resources/test-runner.html: Added.
+
2012-08-14 Keishi Hattori <kei...@webkit.org>
[Chromium] Fix test calendar-picker-appearance.html after r125507
Modified: trunk/LayoutTests/http/tests/inspector/inspector-test.js (125547 => 125548)
--- trunk/LayoutTests/http/tests/inspector/inspector-test.js 2012-08-14 11:47:30 UTC (rev 125547)
+++ trunk/LayoutTests/http/tests/inspector/inspector-test.js 2012-08-14 11:52:00 UTC (rev 125548)
@@ -515,3 +515,6 @@
outputElement = null;
}
}
+
+if (!window.testRunner && window.opener)
+ window.testRunner = window.opener.testRunner;
Added: trunk/LayoutTests/http/tests/inspector/resources/test-runner.html (0 => 125548)
--- trunk/LayoutTests/http/tests/inspector/resources/test-runner.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/resources/test-runner.html 2012-08-14 11:52:00 UTC (rev 125548)
@@ -0,0 +1,233 @@
+<html>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+
+<link rel="stylesheet" type="text/css" href=""
+<style>
+:focus {
+ outline: none;
+}
+
+.failed {
+ color: red;
+}
+
+.timeout {
+ color: brown;
+}
+</style>
+
+<script>
+
+var tests = [];
+var skipList = ["console-api-on-call-frame.html", "debugger/"];
+var treeOutline = null;
+
+function start()
+{
+ scanFolder("inspector/console");
+ scanFolder("inspector/debugger");
+ scanFolder("inspector/editor");
+ scanFolder("inspector/elements");
+ scanFolder("inspector/profiler");
+ scanFolder("inspector/styles");
+ scanFolder("inspector/timeline");
+ scanFolder("inspector");
+
+ document.getElementById("outline").removeChildren();
+ treeOutline = new TreeOutline(document.getElementById("outline"));
+
+ runNextTest();
+}
+
+function stop()
+{
+ tests = [];
+}
+
+function scanFolder(folder)
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", "/LayoutTests/" + folder + "/", false);
+ xhr.send(null);
+ var text = xhr.responseText;
+ var element = document.createElement("div");
+ element.innerHTML = text;
+ var links = element.querySelectorAll("a");
+ for (var i = 0; i < links.length; ++i) {
+ var link = links[i].href;
+ var match = link.match(/[^\/]*\/([^\/]+\.html)$/);
+ if (match)
+ tests.push(folder + "/" + match[1]);
+ }
+}
+
+function runNextTest(lastResult)
+{
+ if (lastResult) {
+ var element = document.getElementById(lastResult);
+ element.textContent = parseInt(element.textContent) + 1;
+ }
+ var testPath = tests.shift();
+ if (testPath)
+ new StandaloneTestRunner("http://localhost:8000/LayoutTests/" + testPath, runNextTest);
+}
+
+function StandaloneTestRunner(testPath, next)
+{
+ this._testPath = testPath;
+ this._next = next;
+
+ this._treeElement = new TreeElement(testPath);
+ treeOutline.appendChild(this._treeElement);
+
+ for (var i = 0; i < skipList.length; ++i) {
+ if (testPath.indexOf(skipList[i]) !== -1) {
+ this._treeElement.title = testPath + ": SKIPPED";
+ this._next("skip");
+ return;
+ }
+ }
+
+ this._testPage = window.open("about:blank", "inspected", "width=800,height=600");
+
+ window.remoteDebuggingHandshake = this._remoteDebuggingHandshake.bind(this);
+ var script = document.createElement("script");
+ script.src = ""
+ document.head.appendChild(script);
+}
+
+StandaloneTestRunner.FrontendLocation = "http://localhost:8000/Source/WebCore/inspector/front-end/";
+
+StandaloneTestRunner.prototype = {
+ _remoteDebuggingHandshake: function(data)
+ {
+ for (var i = 0; i < data.length; ++i) {
+ if (data[i].url !== "about:blank")
+ continue;
+ var debuggerURL = data[i].webSocketDebuggerUrl.replace("://", "=");
+ this._inspectorWindow = window.open(StandaloneTestRunner.FrontendLocation + "inspector.html?" + debuggerURL, "inspector", "width=600,height=400");
+ this._inspectorWindow._onload_ = this._inspectorWindowLoaded.bind(this);
+ }
+ },
+
+ _inspectorWindowLoaded: function()
+ {
+ window.testRunner = this;
+ this._testPage.location.href = ""
+ this._watchDog = setTimeout(this._timeout.bind(this), 10000);
+ },
+
+ dumpAsText: function()
+ {
+ },
+
+ waitUntilDone: function()
+ {
+ },
+
+ closeWebInspector: function()
+ {
+ this._inspectorWindow.close();
+ },
+
+ notifyDone: function(timeout)
+ {
+ if (this._done)
+ return;
+ this._done = true;
+
+ var actual = this._testPage.document.body.innerText + "\n";
+ this._testPage.close();
+ this._inspectorWindow.close();
+ clearTimeout(this._watchDog);
+
+ var xhr = new XMLHttpRequest();
+ var ext = this._testPath.lastIndexOf(".");
+ xhr.open("GET", this._testPath.substring(0, ext) + "-expected.txt", false);
+ xhr.send(null);
+ var expected = xhr.responseText;
+ if (actual === expected) {
+ this._treeElement.title = this._testPath + ": SUCCESS";
+ this._next("pass");
+ return;
+ }
+
+ this._treeElement.title = this._testPath + ": FAILED";
+ this._treeElement.listItemElement.addStyleClass("failed");
+
+ var baseLines = difflib.stringAsLines(expected);
+ var newLines = difflib.stringAsLines(actual);
+ var sm = new difflib.SequenceMatcher(baseLines, newLines);
+ var opcodes = sm.get_opcodes();
+ var lastWasSeparator = false;
+
+ for (var idx = 0; idx < opcodes.length; idx++) {
+ var code = opcodes[idx];
+ var change = code[0];
+ var b = code[1];
+ var be = code[2];
+ var n = code[3];
+ var ne = code[4];
+ var rowCount = Math.max(be - b, ne - n);
+ var topRows = [];
+ var bottomRows = [];
+ for (var i = 0; i < rowCount; i++) {
+ if (change === "delete" || (change === "replace" && b < be)) {
+ var lineNumber = b++;
+ this._treeElement.appendChild(new TreeElement("- [" + lineNumber + "] " + baseLines[lineNumber]));
+ }
+
+ if (change === "insert" || (change === "replace" && n < ne)) {
+ var lineNumber = n++;
+ this._treeElement.appendChild(new TreeElement("+ [" + lineNumber + "] " + newLines[lineNumber]));
+ }
+
+ if (change === "equal") {
+ b++;
+ n++;
+ }
+ }
+ }
+
+ this._next("fail");
+ },
+
+ evaluateInWebInspector: function(callId, script)
+ {
+ this._inspectorWindow.postMessage(["evaluateForTest", callId, script], "*");
+ },
+
+ _timeout: function()
+ {
+ this._treeElement.title = this._testPath + ": TIMEOUT";
+ this._treeElement.listItemElement.addStyleClass("timeout");
+ this._done = true;
+ this._testPage.close();
+ this._inspectorWindow.close();
+ this._next("timeout");
+ }
+}
+
+</script>
+<body>
+This is a standalone test suite for inspector front-end. Here is how you run it:<br>
+1) Start serving WebKit folder off port 8000 so that this page would have following address:
+<a href=""
+>http://localhost:8000/LayoutTests/http/tests/inspector/resources/test-runner.html</a><br>
+2) Run Chrome Canary (ToT Chromium) with following flags:
+ --remote-debugging-port=9222 --user-data-dir=testProfile http://localhost:8000/LayoutTests/http/tests/inspector/resources/test-runner.html<br><br>
+
+<button _onclick_="start()">Start</button>
+<button _onclick_="stop()">Stop</button>
+
+<span>Pass: <span id="pass">0</span></span>
+<span>Fail: <span id="fail">0</span></span>
+<span>Timeout: <span id="timeout">0</span></span>
+<span>Skip: <span id="skip">0</span></span>
+
+<ol id="outline" style="font-size: 12px !important" class="source-code outline-disclosure"></ol>
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector/resources/test-runner.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (125547 => 125548)
--- trunk/Source/WebCore/ChangeLog 2012-08-14 11:47:30 UTC (rev 125547)
+++ trunk/Source/WebCore/ChangeLog 2012-08-14 11:52:00 UTC (rev 125548)
@@ -1,3 +1,19 @@
+2012-08-14 Pavel Feldman <pfeld...@chromium.org>
+
+ Web Inspector: add external test runner for running inspector front-end tests with no TestRunner infrastructure.
+ https://bugs.webkit.org/show_bug.cgi?id=93833
+
+ Reviewed by Yury Semikhatsky.
+
+ Added mock test runner that allows running front-end layout tests.
+ InspectorFrontendAPI can now dispatch whatever it receives from its embedder (opener).
+
+ * inspector/front-end/InspectorFrontendAPI.js:
+ (InspectorFrontendAPI.evaluateForTest):
+ (InspectorFrontendAPI.dispatch):
+ (InspectorFrontendAPI.loadCompleted):
+ (.onMessageFromOpener):
+
2012-08-14 Allan Sandfeld Jensen <allan.jen...@nokia.com>
[Qt] Incomplete repaint of link underline
Modified: trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js (125547 => 125548)
--- trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js 2012-08-14 11:47:30 UTC (rev 125547)
+++ trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js 2012-08-14 11:52:00 UTC (rev 125548)
@@ -120,9 +120,14 @@
WebInspector.setToolbarColors(backgroundColor, color);
},
+ evaluateForTest: function(callId, script)
+ {
+ WebInspector.evaluateForTestInFrontend(callId, script);
+ },
+
dispatch: function(signature)
{
- if (WebInspector.panels) {
+ if (InspectorFrontendAPI._isLoaded) {
var methodName = signature.shift();
return InspectorFrontendAPI[methodName].apply(InspectorFrontendAPI, signature);
}
@@ -131,8 +136,18 @@
loadCompleted: function()
{
+ InspectorFrontendAPI._isLoaded = true;
for (var i = 0; i < InspectorFrontendAPI._pendingCommands.length; ++i)
InspectorFrontendAPI.dispatch(InspectorFrontendAPI._pendingCommands[i]);
InspectorFrontendAPI._pendingCommands = [];
}
}
+
+if (window.opener) {
+ function onMessageFromOpener(event)
+ {
+ if (event.source === window.opener)
+ InspectorFrontendAPI.dispatch(event.data);
+ }
+ window.addEventListener("message", onMessageFromOpener, true);
+}