Permalink
Browse files

Web Inspector: split standalone test runner, test scanner and test stub.

https://bugs.webkit.org/show_bug.cgi?id=94001

Reviewed by Vsevolod Vlasov.

Source/WebCore:

This change starts sending loacCompleted message to the embedder.

* inspector/front-end/InspectorFrontendAPI.js:
(InspectorFrontendAPI.loadCompleted):
* inspector/front-end/test-runner.html: Added.

LayoutTests:

This change allows opening a) test runner, b) layout tests and c) inspector front-end off different
hosts. It is one more step towards extension-driven runner.

* http/tests/inspector/inspector-test.js:
* http/tests/inspector/resources/test-runner.html: Removed.
* http/tests/inspector/resources/test-scanner.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information...
1 parent 470f760 commit 18e8c110f8e3f78d4eaac44120d1cc78995dbbcd @pavelfeldman pavelfeldman committed Aug 15, 2012
View
@@ -1,3 +1,17 @@
+2012-08-14 Pavel Feldman <pfeldman@chromium.org>
+
+ Web Inspector: split standalone test runner, test scanner and test stub.
+ https://bugs.webkit.org/show_bug.cgi?id=94001
+
+ Reviewed by Vsevolod Vlasov.
+
+ This change allows opening a) test runner, b) layout tests and c) inspector front-end off different
+ hosts. It is one more step towards extension-driven runner.
+
+ * http/tests/inspector/inspector-test.js:
+ * http/tests/inspector/resources/test-runner.html: Removed.
+ * http/tests/inspector/resources/test-scanner.html: Added.
+
2012-08-15 Shinya Kawanaka <shinyak@chromium.org>
AuthorShadowDOM for meter element
@@ -516,5 +516,37 @@ function clearOutput()
}
}
+function StandaloneTestRunnerStub()
+{
+}
+
+StandaloneTestRunnerStub.prototype = {
+ dumpAsText: function()
+ {
+ },
+
+ waitUntilDone: function()
+ {
+ },
+
+ closeWebInspector: function()
+ {
+ window.opener.postMessage(["closeWebInspector"], "*");
+ },
+
+ notifyDone: function()
+ {
+ var actual = document.body.innerText + "\n";
+ window.opener.postMessage(["notifyDone", actual], "*");
+ },
+
+ evaluateInWebInspector: function(callId, script)
+ {
+ window.opener.postMessage(["evaluateInWebInspector", callId, script], "*");
+ },
+
+ display: function() { }
+}
+
if (!window.testRunner && window.opener)
- window.testRunner = window.opener.testRunner;
+ window.testRunner = new StandaloneTestRunnerStub();
@@ -1,233 +0,0 @@
-<html>
-<script src="http://localhost:8000/Source/WebCore/inspector/front-end/jsdifflib.js"></script>
-<script src="http://localhost:8000/Source/WebCore/inspector/front-end/utilities.js"></script>
-<script src="http://localhost:8000/Source/WebCore/inspector/front-end/DOMExtension.js"></script>
-<script src="http://localhost:8000/Source/WebCore/inspector/front-end/treeoutline.js"></script>
-
-<link rel="stylesheet" type="text/css" href="http://localhost:8000/Source/WebCore/inspector/front-end/inspector.css">
-<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 = "http://localhost:9222/json?jsonp=remoteDebuggingHandshake";
- 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._testPath;
- 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"
->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>
@@ -0,0 +1,68 @@
+<html>
+<script>
+var tests = [];
+
+scanFolder("inspector/console");
+// scanFolder("inspector/debugger");
+scanFolder("inspector/editor");
+scanFolder("inspector/elements");
+scanFolder("inspector/profiler");
+scanFolder("inspector/styles");
+scanFolder("inspector/timeline");
+scanFolder("inspector");
+
+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)
+ continue;
+ var path = "/LayoutTests/" + folder + "/" + match[1];
+ var expected = fetchExpectations(path);
+ tests.push([path, expected]);
+ }
+}
+
+function fetchExpectations(path)
+{
+ var ext = path.lastIndexOf(".");
+ path = path.substring(0, ext) + "-expected.txt";
+ var chromiumPath = path.replace("/LayoutTests/", "/LayoutTests/platform/chromium/");
+
+ var expectations = fetch(chromiumPath) || fetch(path) || "";
+
+ var expectationLines = expectations.split("\n");
+ var filtered = [];
+ for (var i = 0; i < expectationLines.length; ++i) {
+ if (!expectationLines[i].indexOf("ALERT: ") ||
+ !expectationLines[i].indexOf("CONSOLE MESSAGE: ")) {
+ filtered = [];
+ continue;
+ }
+ filtered.push(expectationLines[i]);
+ }
+ return filtered.join("\n");
+}
+
+function fetch(path)
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", path, false);
+ xhr.send(null);
+ return xhr.status !== 404 ? xhr.responseText : "";
+}
+
+window.parent.postMessage(["tests", tests], "*");
+
+</script>
+<body>
+</body>
+</html>
View
@@ -1,3 +1,16 @@
+2012-08-14 Pavel Feldman <pfeldman@chromium.org>
+
+ Web Inspector: split standalone test runner, test scanner and test stub.
+ https://bugs.webkit.org/show_bug.cgi?id=94001
+
+ Reviewed by Vsevolod Vlasov.
+
+ This change starts sending loacCompleted message to the embedder.
+
+ * inspector/front-end/InspectorFrontendAPI.js:
+ (InspectorFrontendAPI.loadCompleted):
+ * inspector/front-end/test-runner.html: Added.
+
2012-08-15 Shinya Kawanaka <shinyak@chromium.org>
[Refactoring] The debug version and release version of toHTMLSelectElement can be merged without any penalty
@@ -140,6 +140,8 @@ InspectorFrontendAPI = {
for (var i = 0; i < InspectorFrontendAPI._pendingCommands.length; ++i)
InspectorFrontendAPI.dispatch(InspectorFrontendAPI._pendingCommands[i]);
InspectorFrontendAPI._pendingCommands = [];
+ if (window.opener)
+ window.opener.postMessage(["loadCompleted"], "*");
}
}
Oops, something went wrong.

0 comments on commit 18e8c11

Please sign in to comment.