Title: [188452] releases/WebKitGTK/webkit-2.10/LayoutTests
Revision
188452
Author
[email protected]
Date
2015-08-14 03:38:42 -0700 (Fri, 14 Aug 2015)

Log Message

Merge r188406 - Web Inspector: refactor ProtocolTest to be an InjectedTestHarness subclass
https://bugs.webkit.org/show_bug.cgi?id=147954

Reviewed by Joseph Pecoraro.

In preparation for sharing the same test harness API between protocol tests
and frontend tests, this patch refactors ProtocolTest into the desired
class structure. Each type of test (currently: protocol, frontend) extends
InjectedTestHarness and fills in a few key methods for communicating with
the test page-side code.

This patch standardizes on assert() only logging when the condition is false.
Update protocol tests to use ProtocolTestHarness.expectThat, rather than assert.

* http/tests/inspector/resources/ProtocolTestStub.js:
(window.InjectedTestHarness):
(window.InjectedTestHarness.prototype.createAsyncSuite):
(window.InjectedTestHarness.prototype.createSyncSuite):
(window.InjectedTestHarness.prototype.completeTest):
(window.InjectedTestHarness.prototype.addResult):
(window.InjectedTestHarness.prototype.debugLog):
(window.InjectedTestHarness.prototype.evaluateInPage):
(window.InjectedTestHarness.prototype.importScript):
(window.InjectedTestHarness.prototype.get logCount):
(window.InjectedTestHarness.prototype.log):
(window.InjectedTestHarness.prototype.assert):
(window.InjectedTestHarness.prototype.expectThat):

(InjectedTestHarness.AsyncTestSuite): Use a stored reference to the harness
rather than hardcoding a specific InjectedTestHarness instance.

(InjectedTestHarness.AsyncTestSuite.prototype.runTestCasesAndFinish.finish):
(InjectedTestHarness.AsyncTestSuite.prototype.runTestCasesAndFinish):
(InjectedTestHarness.AsyncTestSuite.prototype.runTestCases):

(InjectedTestHarness.SyncTestSuite): Use a stored reference to the harness
rather than hardcoding a specific InjectedTestHarness instance.

(InjectedTestHarness.SyncTestSuite.prototype.runTestCasesAndFinish):
(InjectedTestHarness.SyncTestSuite.prototype.runTestCases):

(ProtocolTestHarness.prototype.completeTest):
(ProtocolTestHarness.prototype.addResult):
(ProtocolTestHarness.prototype.debugLog):
(ProtocolTestHarness.prototype.evaluateInPage):
(ProtocolTestHarness):
(InspectorProtocol.sendCommand):
(InspectorProtocol.awaitCommand):
(InspectorProtocol.awaitEvent.):
(InspectorProtocol.awaitEvent):
(InspectorProtocol.addEventListener):
(InspectorProtocol.sendMessage):
(InspectorProtocol.checkForError):
(InspectorFrontendAPI.dispatchMessageAsync):
(ProtocolTest.AsyncTestSuite): Moved.
(ProtocolTest.AsyncTestSuite.prototype.runTestCasesAndFinish.finish): Moved.
(ProtocolTest.AsyncTestSuite.prototype.runTestCasesAndFinish): Moved.
(ProtocolTest.AsyncTestSuite.prototype.runTestCases): Moved.
(ProtocolTest.SyncTestSuite): Moved.
(ProtocolTest.SyncTestSuite.prototype.runTestCasesAndFinish): Moved.
(ProtocolTest.SyncTestSuite.prototype.runTestCases): Moved.
(ProtocolTest.log): Moved.
(ProtocolTest.assert): Moved.
(ProtocolTest.debugLog): Moved.
(ProtocolTest.completeTest): Moved.
(ProtocolTest.importScript): Moved.
* http/tests/inspector/resources/console-test.js:
(.suite.addTestCase.):
(.suite.addTestCase):
(ProtocolTest.Console.addTestCase):
* http/tests/inspector/resources/protocol-test.js:
(closeTest):
* inspector/console/console-message.html:
* inspector/console/x-frame-options-message.html:
* inspector/debugger/didSampleProbe-multiple-probes.html:
* inspector/dom-debugger/node-removed.html:
* inspector/dom/dom-remove-events.html:
* inspector/runtime/getProperties.html:
* inspector/unit-tests/async-test-suite-expected.txt:
* inspector/unit-tests/async-test-suite.html:
* inspector/unit-tests/sync-test-suite-expected.txt:
* inspector/unit-tests/sync-test-suite.html:

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog	2015-08-14 10:38:42 UTC (rev 188452)
@@ -1,3 +1,88 @@
+2015-08-13  Brian Burg  <[email protected]>
+
+        Web Inspector: refactor ProtocolTest to be an InjectedTestHarness subclass
+        https://bugs.webkit.org/show_bug.cgi?id=147954
+
+        Reviewed by Joseph Pecoraro.
+
+        In preparation for sharing the same test harness API between protocol tests
+        and frontend tests, this patch refactors ProtocolTest into the desired
+        class structure. Each type of test (currently: protocol, frontend) extends
+        InjectedTestHarness and fills in a few key methods for communicating with
+        the test page-side code.
+
+        This patch standardizes on assert() only logging when the condition is false.
+        Update protocol tests to use ProtocolTestHarness.expectThat, rather than assert.
+
+        * http/tests/inspector/resources/ProtocolTestStub.js:
+        (window.InjectedTestHarness):
+        (window.InjectedTestHarness.prototype.createAsyncSuite):
+        (window.InjectedTestHarness.prototype.createSyncSuite):
+        (window.InjectedTestHarness.prototype.completeTest):
+        (window.InjectedTestHarness.prototype.addResult):
+        (window.InjectedTestHarness.prototype.debugLog):
+        (window.InjectedTestHarness.prototype.evaluateInPage):
+        (window.InjectedTestHarness.prototype.importScript):
+        (window.InjectedTestHarness.prototype.get logCount):
+        (window.InjectedTestHarness.prototype.log):
+        (window.InjectedTestHarness.prototype.assert):
+        (window.InjectedTestHarness.prototype.expectThat):
+ 
+        (InjectedTestHarness.AsyncTestSuite): Use a stored reference to the harness
+        rather than hardcoding a specific InjectedTestHarness instance.
+
+        (InjectedTestHarness.AsyncTestSuite.prototype.runTestCasesAndFinish.finish):
+        (InjectedTestHarness.AsyncTestSuite.prototype.runTestCasesAndFinish):
+        (InjectedTestHarness.AsyncTestSuite.prototype.runTestCases):
+ 
+        (InjectedTestHarness.SyncTestSuite): Use a stored reference to the harness
+        rather than hardcoding a specific InjectedTestHarness instance.
+
+        (InjectedTestHarness.SyncTestSuite.prototype.runTestCasesAndFinish):
+        (InjectedTestHarness.SyncTestSuite.prototype.runTestCases):
+
+        (ProtocolTestHarness.prototype.completeTest):
+        (ProtocolTestHarness.prototype.addResult):
+        (ProtocolTestHarness.prototype.debugLog):
+        (ProtocolTestHarness.prototype.evaluateInPage):
+        (ProtocolTestHarness):
+        (InspectorProtocol.sendCommand):
+        (InspectorProtocol.awaitCommand):
+        (InspectorProtocol.awaitEvent.):
+        (InspectorProtocol.awaitEvent):
+        (InspectorProtocol.addEventListener):
+        (InspectorProtocol.sendMessage):
+        (InspectorProtocol.checkForError):
+        (InspectorFrontendAPI.dispatchMessageAsync):
+        (ProtocolTest.AsyncTestSuite): Moved.
+        (ProtocolTest.AsyncTestSuite.prototype.runTestCasesAndFinish.finish): Moved.
+        (ProtocolTest.AsyncTestSuite.prototype.runTestCasesAndFinish): Moved.
+        (ProtocolTest.AsyncTestSuite.prototype.runTestCases): Moved.
+        (ProtocolTest.SyncTestSuite): Moved.
+        (ProtocolTest.SyncTestSuite.prototype.runTestCasesAndFinish): Moved.
+        (ProtocolTest.SyncTestSuite.prototype.runTestCases): Moved.
+        (ProtocolTest.log): Moved.
+        (ProtocolTest.assert): Moved.
+        (ProtocolTest.debugLog): Moved.
+        (ProtocolTest.completeTest): Moved.
+        (ProtocolTest.importScript): Moved.
+        * http/tests/inspector/resources/console-test.js:
+        (.suite.addTestCase.):
+        (.suite.addTestCase):
+        (ProtocolTest.Console.addTestCase):
+        * http/tests/inspector/resources/protocol-test.js:
+        (closeTest):
+        * inspector/console/console-message.html:
+        * inspector/console/x-frame-options-message.html:
+        * inspector/debugger/didSampleProbe-multiple-probes.html:
+        * inspector/dom-debugger/node-removed.html:
+        * inspector/dom/dom-remove-events.html:
+        * inspector/runtime/getProperties.html:
+        * inspector/unit-tests/async-test-suite-expected.txt:
+        * inspector/unit-tests/async-test-suite.html:
+        * inspector/unit-tests/sync-test-suite-expected.txt:
+        * inspector/unit-tests/sync-test-suite.html:
+
 2015-08-13  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: A {Map, WeakMap, Set, WeakSet} object contains itself will hang the console

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/ProtocolTestStub.js (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/ProtocolTestStub.js	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/ProtocolTestStub.js	2015-08-14 10:38:42 UTC (rev 188452)
@@ -25,160 +25,105 @@
  */
 InspectorFrontendAPI = {};
 
-InspectorProtocol = {};
-InspectorProtocol._dispatchTable = [];
-InspectorProtocol._requestId = -1;
-InspectorProtocol.eventHandler = {};
-
-ProtocolTest = {};
-ProtocolTest.logCount = 0;
-
-ProtocolTest.forceSyncDebugLogging = false;
-InspectorProtocol.dumpInspectorProtocolMessages = false;
-
-InspectorProtocol.sendCommand = function(methodOrObject, params, handler)
+InjectedTestHarness = class InjectedTestHarness
 {
-    // Allow new-style arguments object, as in awaitCommand.
-    var method = methodOrObject;
-    if (typeof methodOrObject === "object")
-        var {method, params, handler} = methodOrObject;
+    constructor()
+    {
+        this._logCount = 0;
+        this.forceSyncDebugLogging = false;
+    }
 
-    this._dispatchTable[++this._requestId] = handler;
-    var messageObject = {method, params, "id": this._requestId};
-    this.sendMessage(messageObject);
+    completeTest()
+    {
+        throw new Error("Must be implemented by subclasses.");
+    }
 
-    return this._requestId;
-}
+    addResult()
+    {
+        throw new Error("Must be implemented by subclasses.");
+    }
 
-InspectorProtocol.awaitCommand = function(args)
-{
-    var {method, params} = args;
-    return new Promise(function(resolve, reject) {
-        this._dispatchTable[++this._requestId] = {resolve, reject};
-        var messageObject = {method, params, "id": this._requestId};
-        this.sendMessage(messageObject);
-    }.bind(this));
-}
+    debugLog()
+    {
+        throw new Error("Must be implemented by subclasses.");
+    }
 
-InspectorProtocol.awaitEvent = function(args)
-{
-    var {event} = args;
-    if (typeof event !== "string")
-        throw new Error("Event must be a string.");
+    evaluateInPage(string, callback)
+    {
+        throw new Error("Must be implemented by subclasses.");
+    }
 
-    return new Promise(function(resolve, reject) {
-        InspectorProtocol.eventHandler[event] = function(message) {
-            InspectorProtocol.eventHandler[event] = undefined;
-            resolve(message);
-        }
-    });
-}
+    createAsyncSuite(name)
+    {
+        return new InjectedTestHarness.AsyncTestSuite(this, name);
+    }
 
-InspectorProtocol.addEventListener = function(eventTypeOrObject, listener)
-{
-    var event = eventTypeOrObject;
-    if (typeof eventTypeOrObject === "object")
-        var {event, listener} = eventTypeOrObject;
+    createSyncSuite(name)
+    {
+        return new InjectedTestHarness.SyncTestSuite(this, name);
+    }
 
-    if (typeof event !== "string")
-        throw new Error("Event name must be a string.");
+    importScript(scriptName)
+    {
+        var xhr = new XMLHttpRequest();
+        var isAsyncRequest = false;
+        xhr.open("GET", scriptName, isAsyncRequest);
+        xhr.send(null);
+        if (xhr.status !== 0 && xhr.status !== 200)
+            throw new Error("Invalid script URL: " + scriptName);
+        var script = `// From InjectedTestHarness.importScript(${scriptName})
+try {
+    ${xhr.responseText}
+} catch (e) {
+    alert(${JSON.stringify("Error in: " + scriptName)});
+    throw e;
+}`;
+        window.eval(script);
+    }
 
-    if (typeof listener !== "function")
-        throw new Error("Event listener must be callable.");
+    get logCount()
+    {
+        return this._logCount;
+    }
 
-    // Convert to an array of listeners.
-    var listeners = InspectorProtocol.eventHandler[event];
-    if (!listeners)
-        listeners = InspectorProtocol.eventHandler[event] = [];
-    else if (typeof listeners === "function")
-        listeners = InspectorProtocol.eventHandler[event] = [listeners];
+    log(message)
+    {
+        ++this._logCount;
 
-    // Prevent registering multiple times.
-    if (listeners.includes(listener))
-        throw new Error("Cannot register the same listener more than once.");
-
-    listeners.push(listener);
-}
-
-InspectorProtocol.sendMessage = function(messageObject)
-{
-    // This matches the debug dumping in InspectorBackend, which is bypassed
-    // by InspectorProtocol. Return messages should be dumped by InspectorBackend.
-    if (this.dumpInspectorProtocolMessages)
-        console.log("frontend: " + JSON.stringify(messageObject));
-
-    InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject));
-}
-
-InspectorProtocol.checkForError = function(responseObject)
-{
-    if (responseObject.error) {
-        ProtocolTest.log("PROTOCOL ERROR: " + JSON.stringify(responseObject.error));
-        ProtocolTest.completeTest();
-        throw "PROTOCOL ERROR";
+        if (this.forceSyncDebugLogging)
+            this.debugLog(message);
+        else
+            this.addResult(message);
     }
-}
 
-InspectorFrontendAPI.dispatchMessageAsync = function(messageObject)
-{
-    // If the message has an id, then it is a reply to a command.
-    var messageId = messageObject["id"];
-    if (typeof messageId === "number") {
-        var handler = InspectorProtocol._dispatchTable[messageId];
-        if (!handler)
+    assert(condition, message)
+    {
+        if (condition)
             return;
 
-        if (typeof handler === "function")
-            handler(messageObject);
-        else if (typeof handler === "object") {
-            var {resolve, reject} = handler;
-            if ("error" in messageObject)
-                reject(messageObject.error.message);
-            else
-                resolve(messageObject.result);
-        }
-    // Otherwise, it is an event.
-    } else {
-        var eventName = messageObject["method"];
-        var handler = InspectorProtocol.eventHandler[eventName];
-        if (!handler)
-            return;
+        let stringifiedMessage = typeof message !== "object" ? message : JSON.stringify(message);
+        this.addResult("ASSERT: " + stringifiedMessage);
+    }
 
-        if (typeof handler === "function")
-            handler(messageObject);
-        else if (handler instanceof Array) {
-            handler.map(function(listener) {
-                listener.call(null, messageObject);
-            });
-        } else if (typeof handler === "object") {
-            var {resolve, reject} = handler;
-            if ("error" in messageObject)
-                reject(messageObject.error.message);
-            else
-                resolve(messageObject.result);
-        }
+    expectThat(condition, message)
+    {
+        let prefix = condition ? "PASS" : "FAIL";
+        let stringifiedMessage = typeof message !== "object" ? message : JSON.stringify(message);
+        this.addResult(prefix + ": " + stringifiedMessage);
     }
 }
 
-window.addEventListener("message", function(event) {
-    try {
-        eval(event.data);
-    } catch (e) {
-        alert(e.stack);
-        ProtocolTest.completeTest();
-        throw e;
-    }
-});
+InjectedTestHarness.AsyncTestSuite = class AsyncTestSuite
+{
+    constructor(harness, name) {
+        if (!(harness instanceof InjectedTestHarness))
+            throw new Error("Must pass the test's harness as the first argument.");
 
-// FIXME: Everything below here should be extracted to a file containing shared test utilities
-// between the two harnesses.
-
-ProtocolTest.AsyncTestSuite = class AsyncTestSuite {
-    constructor(name) {
         if (!name || typeof name !== "string")
             throw new Error("Tried to create AsyncTestSuite without string suite name.");
 
         this.name = name;
+        this._harness = harness;
 
         this.testcases = [];
         this.runCount = 0;
@@ -217,12 +162,12 @@
     runTestCasesAndFinish()
     {
         function finish() {
-            ProtocolTest.completeTest();
+            this._harness.completeTest();
         }
 
         this.runTestCases()
-            .then(finish)
-            .catch(finish);
+            .then(finish.bind(this))
+            .catch(finish.bind(this));
     }
 
     runTestCases()
@@ -234,19 +179,19 @@
 
         this._startedRunning = true;
 
-        ProtocolTest.log("");
-        ProtocolTest.log("== Running test suite: " + this.name);
+        this._harness.log("");
+        this._harness.log("== Running test suite: " + this.name);
 
         // Avoid adding newlines if nothing was logged.
-        var priorLogCount = ProtocolTest.logCount;
+        var priorLogCount = this._harness.logCount;
         var suite = this;
         var result = this.testcases.reduce(function(chain, testcase, i) {
             return chain.then(function() {
-                if (i > 0 && priorLogCount + 1 < ProtocolTest.logCount)
-                    ProtocolTest.log("");
+                if (i > 0 && priorLogCount + 1 < suite._harness.logCount)
+                    suite._harness.log("");
 
-                priorLogCount = ProtocolTest.logCount;
-                ProtocolTest.log("-- Running test case: " + testcase.name);
+                priorLogCount = suite._harness.logCount;
+                suite._harness.log("-- Running test case: " + testcase.name);
                 suite.runCount++;
                 return new Promise(testcase.test);
             });
@@ -261,18 +206,23 @@
             if (typeof message !== "string")
                 message = JSON.stringify(message);
 
-            ProtocolTest.log("!! EXCEPTION: " + message);
+            suite._harness.log("!! EXCEPTION: " + message);
             throw e; // Reject this promise by re-throwing the error.
         });
     }
 }
 
-ProtocolTest.SyncTestSuite = class SyncTestSuite {
-    constructor(name) {
+InjectedTestHarness.SyncTestSuite = class SyncTestSuite
+{
+    constructor(harness, name) {
+        if (!(harness instanceof InjectedTestHarness))
+            throw new Error("Must pass the test's harness as the first argument.");
+
         if (!name || typeof name !== "string")
             throw new Error("Tried to create SyncTestSuite without string suite name.");
 
         this.name = name;
+        this._harness = harness;
 
         this.testcases = [];
         this.runCount = 0;
@@ -310,7 +260,7 @@
     runTestCasesAndFinish()
     {
         this.runTestCases();
-        ProtocolTest.completeTest();
+        this._harness.completeTest();
     }
 
     runTestCases()
@@ -322,19 +272,19 @@
 
         this._startedRunning = true;
 
-        ProtocolTest.log("");
-        ProtocolTest.log("== Running test suite: " + this.name);
+        this._harness.log("");
+        this._harness.log("== Running test suite: " + this.name);
 
-        var priorLogCount = ProtocolTest.logCount;
+        var priorLogCount = this._harness.logCount;
         var suite = this;
         for (var i = 0; i < this.testcases.length; i++) {
             var testcase = this.testcases[i];
-            if (i > 0 && priorLogCount + 1 < ProtocolTest.logCount)
-                ProtocolTest.log("");
+            if (i > 0 && priorLogCount + 1 < this._harness.logCount)
+                this._harness.log("");
 
-            priorLogCount = ProtocolTest.logCount;
+            priorLogCount = this._harness.logCount;
 
-            ProtocolTest.log("-- Running test case: " + testcase.name);
+            this._harness.log("-- Running test case: " + testcase.name);
             suite.runCount++;
             try {
                 var result = testcase.test.call(null);
@@ -353,7 +303,7 @@
                 if (typeof message !== "string")
                     message = JSON.stringify(message);
 
-                ProtocolTest.log("!! EXCEPTION: " + message);
+                this._harness.log("!! EXCEPTION: " + message);
                 return false;
             }
         }
@@ -362,46 +312,187 @@
     }
 }
 
-// Logs a message to test document.
-ProtocolTest.log = function(message)
+class ProtocolTestHarness extends InjectedTestHarness
 {
-    ++ProtocolTest.logCount;
+    // InjectedTestHarness Overrides
 
-    if (this.forceSyncDebugLogging)
-        this.debugLog(message);
-    else
-        InspectorProtocol.sendCommand("Runtime.evaluate", { "_expression_": "log(" + JSON.stringify(message) + ")" } );
+    completeTest()
+    {
+        this.evaluateInPage("closeTest();");
+    }
+
+    addResult(message)
+    {
+        // Unfortunately, every string argument must be escaped because tests are not consistent
+        // with respect to escaping with single or double quotes. Some exceptions use single quotes.
+        var stringifiedMessage = typeof message !== "string" ? JSON.stringify(message) : message;
+        this.evaluateInPage("log(unescape('" + escape(stringifiedMessage) + "'));");
+    }
+
+    debugLog(message)
+    {
+        var stringifiedMessage = typeof message !== "string" ? JSON.stringify(message) : message;
+        this.evaluateInPage("debugLog(unescape('" + escape(stringifiedMessage) + "'));")
+    }
+
+    evaluateInPage(_expression_, callback)
+    {
+        let args = {
+            method: "Runtime.evaluate",
+            params: {_expression_}
+        }
+
+        if (typeof callback === "function")
+            InspectorProtocol.sendCommand(args, callback);
+        else
+            return InspectorProtocol.awaitCommand(args);
+    }
 }
 
-// Logs an assertion result to the test document.
-ProtocolTest.assert = function(condition, message)
+window.ProtocolTest = new ProtocolTestHarness();
+
+InspectorProtocol = {};
+InspectorProtocol._dispatchTable = [];
+InspectorProtocol._requestId = -1;
+InspectorProtocol.eventHandler = {};
+
+InspectorProtocol.dumpInspectorProtocolMessages = false;
+
+InspectorProtocol.sendCommand = function(methodOrObject, params, handler)
 {
-    var status = condition ? "PASS" : "FAIL";
-    var message = typeof message !== "string" ? JSON.stringify(message) : message;
-    var formattedMessage = status + ": " + message;
-    this.log(formattedMessage);
+    // Allow new-style arguments object, as in awaitCommand.
+    var method = methodOrObject;
+    if (typeof methodOrObject === "object")
+        var {method, params, handler} = methodOrObject;
+
+    this._dispatchTable[++this._requestId] = handler;
+    var messageObject = {method, params, "id": this._requestId};
+    this.sendMessage(messageObject);
+
+    return this._requestId;
 }
 
-// Logs message a directly to stdout of the test process via alert function.
-// This message should survive process crash or kill by timeout.
-ProtocolTest.debugLog = function(message)
+InspectorProtocol.awaitCommand = function(args)
 {
-    InspectorProtocol.sendCommand("Runtime.evaluate", { "_expression_": "debugLog(" + JSON.stringify(message) + ")" } );
+    var {method, params} = args;
+    return new Promise(function(resolve, reject) {
+        this._dispatchTable[++this._requestId] = {resolve, reject};
+        var messageObject = {method, params, "id": this._requestId};
+        this.sendMessage(messageObject);
+    }.bind(this));
 }
 
-ProtocolTest.completeTest = function()
+InspectorProtocol.awaitEvent = function(args)
 {
-    InspectorProtocol.sendCommand("Runtime.evaluate", { "_expression_": "closeTest();"} );
+    var {event} = args;
+    if (typeof event !== "string")
+        throw new Error("Event must be a string.");
+
+    return new Promise(function(resolve, reject) {
+        InspectorProtocol.eventHandler[event] = function(message) {
+            InspectorProtocol.eventHandler[event] = undefined;
+            resolve(message);
+        }
+    });
 }
 
-ProtocolTest.importScript = function(scriptName)
+InspectorProtocol.addEventListener = function(eventTypeOrObject, listener)
 {
-    var xhr = new XMLHttpRequest();
-    var isAsyncRequest = false;
-    xhr.open("GET", scriptName, isAsyncRequest);
-    xhr.send(null);
-    if (xhr.status !== 0 && xhr.status !== 200)
-        throw new Error("Invalid script URL: " + scriptName);
-    var script = "try { " + xhr.responseText + "} catch (e) { alert(" + JSON.stringify("Error in: " + scriptName) + "); throw e; }";
-    window.eval(script);
+    var event = eventTypeOrObject;
+    if (typeof eventTypeOrObject === "object")
+        var {event, listener} = eventTypeOrObject;
+
+    if (typeof event !== "string")
+        throw new Error("Event name must be a string.");
+
+    if (typeof listener !== "function")
+        throw new Error("Event listener must be callable.");
+
+    // Convert to an array of listeners.
+    var listeners = InspectorProtocol.eventHandler[event];
+    if (!listeners)
+        listeners = InspectorProtocol.eventHandler[event] = [];
+    else if (typeof listeners === "function")
+        listeners = InspectorProtocol.eventHandler[event] = [listeners];
+
+    // Prevent registering multiple times.
+    if (listeners.includes(listener))
+        throw new Error("Cannot register the same listener more than once.");
+
+    listeners.push(listener);
 }
+
+InspectorProtocol.sendMessage = function(messageObject)
+{
+    // This matches the debug dumping in InspectorBackend, which is bypassed
+    // by InspectorProtocol. Return messages should be dumped by InspectorBackend.
+    if (InspectorProtocol.dumpInspectorProtocolMessages)
+        console.log("frontend: " + JSON.stringify(messageObject));
+
+    InspectorFrontendHost.sendMessageToBackend(JSON.stringify(messageObject));
+}
+
+InspectorProtocol.checkForError = function(responseObject)
+{
+    if (responseObject.error) {
+        ProtocolTest.log("PROTOCOL ERROR: " + JSON.stringify(responseObject.error));
+        ProtocolTest.completeTest();
+        throw "PROTOCOL ERROR";
+    }
+}
+
+InspectorFrontendAPI.dispatchMessageAsync = function(messageObject)
+{
+    // This matches the debug dumping in InspectorBackend, which is bypassed
+    // by InspectorProtocol. Return messages should be dumped by InspectorBackend.
+    if (InspectorProtocol.dumpInspectorProtocolMessages)
+        console.log("backend: " + JSON.stringify(messageObject));
+
+    // If the message has an id, then it is a reply to a command.
+    var messageId = messageObject["id"];
+    if (typeof messageId === "number") {
+        var handler = InspectorProtocol._dispatchTable[messageId];
+        if (!handler)
+            return;
+
+        if (typeof handler === "function")
+            handler(messageObject);
+        else if (typeof handler === "object") {
+            var {resolve, reject} = handler;
+            if ("error" in messageObject)
+                reject(messageObject.error.message);
+            else
+                resolve(messageObject.result);
+        }
+    // Otherwise, it is an event.
+    } else {
+        var eventName = messageObject["method"];
+        var handler = InspectorProtocol.eventHandler[eventName];
+        if (!handler)
+            return;
+
+        if (typeof handler === "function")
+            handler(messageObject);
+        else if (handler instanceof Array) {
+            handler.map(function(listener) {
+                listener.call(null, messageObject);
+            });
+        } else if (typeof handler === "object") {
+            var {resolve, reject} = handler;
+            if ("error" in messageObject)
+                reject(messageObject.error.message);
+            else
+                resolve(messageObject.result);
+        }
+    }
+}
+
+window.addEventListener("message", function(event) {
+    try {
+        eval(event.data);
+    } catch (e) {
+        alert(e.stack);
+        ProtocolTest.completeTest();
+        throw e;
+    }
+});
\ No newline at end of file

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/console-test.js (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/console-test.js	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/console-test.js	2015-08-14 10:38:42 UTC (rev 188452)
@@ -32,7 +32,7 @@
 
 ProtocolTest.Console.addTestCase = function(suite, args)
 {
-    if (!(suite instanceof ProtocolTest.AsyncTestSuite))
+    if (!(suite instanceof InjectedTestHarness.AsyncTestSuite))
         throw new Error("Console test cases must be added to an async test suite.");
 
     var {name, description, _expression_, expected} = args;
@@ -46,17 +46,17 @@
             .then(function(messageObject) {
                 var consoleMessage = messageObject.params.message;
                 var {source, level, text, parameters} = consoleMessage;
-                ProtocolTest.assert(source === expected.source, "ConsoleMessage type should be '" + expected.source + "'.");
-                ProtocolTest.assert(level === expected.level, "ConsoleMessage level should be '" + expected.level + "'.");
+                ProtocolTest.expectThat(source === expected.source, "ConsoleMessage type should be '" + expected.source + "'.");
+                ProtocolTest.expectThat(level === expected.level, "ConsoleMessage level should be '" + expected.level + "'.");
 
                 if (expected.text)
-                    ProtocolTest.assert(text === expected.text, "ConsoleMessage text should be '" + expected.text + "'.");
+                    ProtocolTest.expectThat(text === expected.text, "ConsoleMessage text should be '" + expected.text + "'.");
 
                 if (expected.parameters) {
-                    ProtocolTest.assert(parameters.length === expected.parameters.length, "ConsoleMessage parameters.length === " + expected.parameters.length);
+                    ProtocolTest.expectThat(parameters.length === expected.parameters.length, "ConsoleMessage parameters.length === " + expected.parameters.length);
                     for (var i = 0; i < parameters.length; ++i) {
                         var expectedType = expected.parameters[i];
-                        ProtocolTest.assert(parameters[i].type === expectedType, "ConsoleMessage parameter " + i + " should have type '" + expectedType + "'.");
+                        ProtocolTest.expectThat(parameters[i].type === expectedType, "ConsoleMessage parameter " + i + " should have type '" + expectedType + "'.");
                     }
                 }
 

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/protocol-test.js (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/protocol-test.js	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/http/tests/inspector/resources/protocol-test.js	2015-08-14 10:38:42 UTC (rev 188452)
@@ -59,6 +59,7 @@
 function closeTest()
 {
     window.internals.closeDummyInspectorFrontend();
+
     // This code might be executed while the debugger is still running through a stack based EventLoop.
     // Use a setTimeout to defer to a clean stack before letting the testRunner load the next test.
     setTimeout(function() {

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/console/console-message.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/console/console-message.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/console/console-message.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -16,7 +16,7 @@
 {
     ProtocolTest.importScript("console-test.js");
 
-    var suite = new ProtocolTest.AsyncTestSuite("Console.MessagesFromCommandLineAPI");
+    var suite = ProtocolTest.createAsyncSuite("Console.MessagesFromCommandLineAPI");
 
     ProtocolTest.Console.addTestCase(suite, {
         name: "ConsoleLogString",

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/console/x-frame-options-message.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/console/x-frame-options-message.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/console/x-frame-options-message.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -7,7 +7,7 @@
 {
     ProtocolTest.importScript("console-test.js");
 
-    let suite = new ProtocolTest.AsyncTestSuite("Console.XFrameOptionsMessages");
+    let suite = ProtocolTest.createAsyncSuite("Console.XFrameOptionsMessages");
 
     ProtocolTest.Console.addTestCase(suite, {
         name: "XFrameOptionsDeny",

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/debugger/didSampleProbe-multiple-probes.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/debugger/didSampleProbe-multiple-probes.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/debugger/didSampleProbe-multiple-probes.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -78,7 +78,7 @@
         if (receivedAllExpectedSamples()) {
             tests.forEach(function(test) {
                 var result = test.predicate();
-                ProtocolTest.assert(result, test.message);
+                ProtocolTest.expectThat(result, test.message);
                 if (!result)
                     test.error();
             });

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/dom/dom-remove-events.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/dom/dom-remove-events.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/dom/dom-remove-events.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -47,15 +47,15 @@
     function onChildNodeRemoved(response)
     {
         var nodeId = response.params.nodeId;
-        ProtocolTest.assert(getNodeIdentifier(nodeId) === "target_element", "onChildNodeRemoved called for #target_element");
+        ProtocolTest.expectThat(getNodeIdentifier(nodeId) === "target_element", "onChildNodeRemoved called for #target_element");
         delete nodesById[nodeId];
     }
 
     function onChildNodeInserted(response)
     {
         collectNode(response.params.node);
-        ProtocolTest.assert(getNodeIdentifier(response.params.parentNodeId) === "final_container", "onChildNodeInserted called for parent node #final_container");
-        ProtocolTest.assert(getNodeIdentifier(response.params.node.nodeId) === "target_element", "onChildNodeInserted called for child node #target_element");
+        ProtocolTest.expectThat(getNodeIdentifier(response.params.parentNodeId) === "final_container", "onChildNodeInserted called for parent node #final_container");
+        ProtocolTest.expectThat(getNodeIdentifier(response.params.node.nodeId) === "target_element", "onChildNodeInserted called for child node #target_element");
     }
 
     InspectorProtocol.sendCommand("DOM.getDocument", {}, onGotDocument);

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/dom-debugger/node-removed.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/dom-debugger/node-removed.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/dom-debugger/node-removed.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -70,15 +70,15 @@
     function onChildNodeRemoved(response)
     {
         var nodeId = response.params.nodeId;
-        ProtocolTest.assert(getNodeIdentifier(nodeId) === "div#target_element", "onChildNodeRemoved called for #target_element");
+        ProtocolTest.expectThat(getNodeIdentifier(nodeId) === "div#target_element", "onChildNodeRemoved called for #target_element");
         delete nodesById[nodeId];
     }
 
     function onChildNodeInserted(response)
     {
         collectNode(response.params.node);
-        ProtocolTest.assert(getNodeIdentifier(response.params.parentNodeId) === "div#final_container", "onChildNodeInserted called for parent node #final_container");
-        ProtocolTest.assert(getNodeIdentifier(response.params.node.nodeId) === "div#target_element", "onChildNodeInserted called for child node #target_element");
+        ProtocolTest.expectThat(getNodeIdentifier(response.params.parentNodeId) === "div#final_container", "onChildNodeInserted called for parent node #final_container");
+        ProtocolTest.expectThat(getNodeIdentifier(response.params.node.nodeId) === "div#target_element", "onChildNodeInserted called for child node #target_element");
     }
 
     function onDebuggerPaused(response)

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/runtime/getProperties.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/runtime/getProperties.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/runtime/getProperties.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -4,7 +4,7 @@
 <script>
 function test()
 {
-    var suite = new ProtocolTest.AsyncTestSuite("Runtime.getProperties");
+    var suite = ProtocolTest.createAsyncSuite("Runtime.getProperties");
 
     addGetPropertiesTestCase({
         name: "CheckPropertiesOfWrapperObject",

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/async-test-suite-expected.txt (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/async-test-suite-expected.txt	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/async-test-suite-expected.txt	2015-08-14 10:38:42 UTC (rev 188452)
@@ -1,5 +1,6 @@
 PASS: instantiating AsyncTestSuite requires name argument.
 PASS: instantiating AsyncTestSuite requires string name argument.
+PASS: instantiating AsyncTestSuite requires test harness argument.
 PASS: should not be able to add empty test case.
 PASS: should not be able to add non-object test case.
 PASS: test case should require string name.

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/async-test-suite.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/async-test-suite.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/async-test-suite.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -6,21 +6,28 @@
 function test()
 {
     try {
-        new ProtocolTest.AsyncTestSuite();
+        let result = new InjectedTestHarness.AsyncTestSuite(this);
         ProtocolTest.log("FAIL: instantiating AsyncTestSuite requires name argument.");
     } catch (e) {
         ProtocolTest.log("PASS: instantiating AsyncTestSuite requires name argument.");
     }
 
     try {
-        new ProtocolTest.AsyncTestSuite({});
+        let result = new InjectedTestHarness.AsyncTestSuite(this, {});
         ProtocolTest.log("FAIL: instantiating AsyncTestSuite requires string name argument.");
     } catch (e) {
         ProtocolTest.log("PASS: instantiating AsyncTestSuite requires string name argument.");
     }
 
-    var badArgsSuite = new ProtocolTest.AsyncTestSuite("dummy");
     try {
+        let result = new InjectedTestHarness.AsyncTestSuite("something", {});
+        ProtocolTest.log("FAIL: instantiating AsyncTestSuite requires test harness argument.");
+    } catch (e) {
+        ProtocolTest.log("PASS: instantiating AsyncTestSuite requires test harness argument.");
+    }
+
+    var badArgsSuite = ProtocolTest.createAsyncSuite("dummy");
+    try {
         badArgsSuite.addTestCase();
         ProtocolTest.log("FAIL: should not be able to add empty test case.");
     } catch (e) {
@@ -51,7 +58,7 @@
         ProtocolTest.log("PASS: test case should require test function.");
     }
 
-    var runEmptySuite = new ProtocolTest.AsyncTestSuite("AsyncTestSuite.RunEmptySuite");
+    var runEmptySuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.RunEmptySuite");
     try {
         runEmptySuite.runTestCases();
         ProtocolTest.log("FAIL: should not be able to run empty test suite.");
@@ -59,7 +66,7 @@
         ProtocolTest.log("PASS: should not be able to run empty test suite.");
     }
 
-    var runTwiceSuite = new ProtocolTest.AsyncTestSuite("AsyncTestSuite.RunTwiceSuite");
+    var runTwiceSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.RunTwiceSuite");
     runTwiceSuite.addTestCase({
         name: "DummyTest0",
         description: "Check that a suite can't run more than once.",
@@ -81,7 +88,7 @@
     var rejectToken = {"token": 666};
     var thrownError = new Error(rejectToken);
 
-    var sequentialExecutionSuite = new ProtocolTest.AsyncTestSuite("AsyncTestSuite.SequentialExecution");
+    var sequentialExecutionSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.SequentialExecution");
     sequentialExecutionSuite.addTestCase({
         name: "DummyTest1",
         description: "Check test case execution order.",
@@ -111,7 +118,7 @@
         }
     });
 
-    var abortOnFailureSuite = new ProtocolTest.AsyncTestSuite("AsyncTestSuite.AbortOnFailure");
+    var abortOnFailureSuite = ProtocolTest.createAsyncSuite("AsyncTestSuite.AbortOnFailure");
     abortOnFailureSuite.addTestCase({
         name: "PassingTest5",
         description: "This test is a dummy.",
@@ -136,7 +143,7 @@
 
     result = result.then(function() {
         var promise = sequentialExecutionSuite.runTestCases();
-        ProtocolTest.assert(result instanceof Promise, "AsyncTestSuite.RunTestCases() should return a Promise.");
+        ProtocolTest.expectThat(result instanceof Promise, "AsyncTestSuite.RunTestCases() should return a Promise.");
         return promise;
     });
     result = result.then(function resolved() {
@@ -144,12 +151,12 @@
         return Promise.resolve(); // Continue this test.
     }, function rejected(e) {
         ProtocolTest.log("PASS: Promise from sequentialExecutionSuite.runTestCases() should reject when a test case fails.");
-        ProtocolTest.assert(e === thrownError, "Promise from sequentialExecutionSuite.runTestCases() should reject without altering its result value.");
+        ProtocolTest.expectThat(e === thrownError, "Promise from sequentialExecutionSuite.runTestCases() should reject without altering its result value.");
 
-        ProtocolTest.assert(sequentialExecutionSuite.runCount === 4, "sequentialExecutionSuite should have executed four tests.");
-        ProtocolTest.assert(sequentialExecutionSuite.passCount === 3, "sequentialExecutionSuite should have passed three tests.");
-        ProtocolTest.assert(sequentialExecutionSuite.failCount === 1, "sequentialExecutionSuite should have failed 1 test.");
-        ProtocolTest.assert(sequentialExecutionSuite.skipCount === 0, "sequentialExecutionSuite should have skipped zero tests.");
+        ProtocolTest.expectThat(sequentialExecutionSuite.runCount === 4, "sequentialExecutionSuite should have executed four tests.");
+        ProtocolTest.expectThat(sequentialExecutionSuite.passCount === 3, "sequentialExecutionSuite should have passed three tests.");
+        ProtocolTest.expectThat(sequentialExecutionSuite.failCount === 1, "sequentialExecutionSuite should have failed 1 test.");
+        ProtocolTest.expectThat(sequentialExecutionSuite.skipCount === 0, "sequentialExecutionSuite should have skipped zero tests.");
         return Promise.resolve(); // Continue this test.
     });
 
@@ -160,11 +167,11 @@
         return Promise.resolve(); // Continue this test.
     }, function rejected(e) {
         ProtocolTest.log("PASS: Promise from abortOnFailureSuite.runTestCases() should reject when a test case fails.");
-        ProtocolTest.assert(e === rejectToken, "Promise from abortOnFailureSuite.runTestCases() should reject without altering its result value.");
-        ProtocolTest.assert(abortOnFailureSuite.runCount === 2, "abortOnFailureSuite should have executed two tests.");
-        ProtocolTest.assert(abortOnFailureSuite.passCount === 1, "abortOnFailureSuite should have passed one test.");
-        ProtocolTest.assert(abortOnFailureSuite.failCount === 1, "abortOnFailureSuite should have failed one test.");
-        ProtocolTest.assert(abortOnFailureSuite.skipCount === 1, "abortOnFailureSuite should have skipped one test.");
+        ProtocolTest.expectThat(e === rejectToken, "Promise from abortOnFailureSuite.runTestCases() should reject without altering its result value.");
+        ProtocolTest.expectThat(abortOnFailureSuite.runCount === 2, "abortOnFailureSuite should have executed two tests.");
+        ProtocolTest.expectThat(abortOnFailureSuite.passCount === 1, "abortOnFailureSuite should have passed one test.");
+        ProtocolTest.expectThat(abortOnFailureSuite.failCount === 1, "abortOnFailureSuite should have failed one test.");
+        ProtocolTest.expectThat(abortOnFailureSuite.skipCount === 1, "abortOnFailureSuite should have skipped one test.");
 
         return Promise.resolve(); // Continue this test.
     });

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/sync-test-suite-expected.txt (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/sync-test-suite-expected.txt	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/sync-test-suite-expected.txt	2015-08-14 10:38:42 UTC (rev 188452)
@@ -1,5 +1,6 @@
 PASS: instantiating SyncTestSuite requires name argument.
 PASS: instantiating SyncTestSuite requires string name argument.
+PASS: instantiating SyncTestSuite requires test harness argument.
 PASS: should not be able to add empty test case.
 PASS: should not be able to add non-object test case.
 PASS: test case should require string name.

Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/sync-test-suite.html (188451 => 188452)


--- releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/sync-test-suite.html	2015-08-14 10:36:28 UTC (rev 188451)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/inspector/unit-tests/sync-test-suite.html	2015-08-14 10:38:42 UTC (rev 188452)
@@ -6,21 +6,28 @@
 function test()
 {
     try {
-        new ProtocolTest.SyncTestSuite();
+        let result = new ProtocolTest.SyncTestSuite(this);
         ProtocolTest.log("FAIL: instantiating SyncTestSuite requires name argument.");
     } catch (e) {
         ProtocolTest.log("PASS: instantiating SyncTestSuite requires name argument.");
     }
 
     try {
-        new ProtocolTest.SyncTestSuite({});
+        let result = new ProtocolTest.SyncTestSuite(this, {});
         ProtocolTest.log("FAIL: instantiating SyncTestSuite requires string name argument.");
     } catch (e) {
         ProtocolTest.log("PASS: instantiating SyncTestSuite requires string name argument.");
     }
 
-    var badArgsSuite = new ProtocolTest.SyncTestSuite("dummy");
     try {
+        let result = new ProtocolTest.SyncTestSuite("something", {});
+        ProtocolTest.log("FAIL: instantiating SyncTestSuite requires test harness argument.");
+    } catch (e) {
+        ProtocolTest.log("PASS: instantiating SyncTestSuite requires test harness argument.");
+    }
+
+    var badArgsSuite = ProtocolTest.createSyncSuite("dummy");
+    try {
         badArgsSuite.addTestCase();
         ProtocolTest.log("FAIL: should not be able to add empty test case.");
     } catch (e) {
@@ -51,7 +58,7 @@
         ProtocolTest.log("PASS: test case should require test function.");
     }
 
-    var runEmptySuite = new ProtocolTest.SyncTestSuite("SyncTestSuite.RunEmptySuite");
+    var runEmptySuite = ProtocolTest.createSyncSuite("SyncTestSuite.RunEmptySuite");
     try {
         runEmptySuite.runTestCases();
         ProtocolTest.log("FAIL: should not be able to run empty test suite.");
@@ -59,7 +66,7 @@
         ProtocolTest.log("PASS: should not be able to run empty test suite.");
     }
 
-    var runTwiceSuite = new ProtocolTest.SyncTestSuite("SyncTestSuite.RunTwiceSuite");
+    var runTwiceSuite = ProtocolTest.createSyncSuite("SyncTestSuite.RunTwiceSuite");
     runTwiceSuite.addTestCase({
         name: "DummyTest0",
         description: "Check that a suite can't run more than once.",
@@ -68,7 +75,7 @@
 
     try {
         var result = runTwiceSuite.runTestCases();
-        ProtocolTest.assert(result === true, "Return value of runTwiceSuite.runTestCases() should be true when all tests pass.");
+        ProtocolTest.expectThat(result === true, "Return value of runTwiceSuite.runTestCases() should be true when all tests pass.");
 
         runTwiceSuite.runTestCases(); // Try to trigger an error.
         ProtocolTest.log("FAIL: should not be able to run a test suite twice.");
@@ -78,7 +85,7 @@
 
     var thrownError = new Error({"token": 666});
 
-    var sequentialExecutionSuite = new ProtocolTest.SyncTestSuite("SyncTestSuite.SequentialExecution");
+    var sequentialExecutionSuite = ProtocolTest.createSyncSuite("SyncTestSuite.SequentialExecution");
     sequentialExecutionSuite.addTestCase({
         name: "DummyTest1",
         description: "Check test case execution order.",
@@ -101,13 +108,13 @@
     });
 
     var result = sequentialExecutionSuite.runTestCases();
-    ProtocolTest.assert(result === false, "Return value of sequentialExecutionSuite.runTestCases() should be false when a test case fails.");
-    ProtocolTest.assert(sequentialExecutionSuite.runCount === 4, "sequentialExecutionSuite should have executed four tests.");
-    ProtocolTest.assert(sequentialExecutionSuite.passCount === 3, "sequentialExecutionSuite should have passed three tests.");
-    ProtocolTest.assert(sequentialExecutionSuite.failCount === 1, "sequentialExecutionSuite should have failed 1 test.");
-    ProtocolTest.assert(sequentialExecutionSuite.skipCount === 0, "sequentialExecutionSuite should have skipped zero tests.");
+    ProtocolTest.expectThat(result === false, "Return value of sequentialExecutionSuite.runTestCases() should be false when a test case fails.");
+    ProtocolTest.expectThat(sequentialExecutionSuite.runCount === 4, "sequentialExecutionSuite should have executed four tests.");
+    ProtocolTest.expectThat(sequentialExecutionSuite.passCount === 3, "sequentialExecutionSuite should have passed three tests.");
+    ProtocolTest.expectThat(sequentialExecutionSuite.failCount === 1, "sequentialExecutionSuite should have failed 1 test.");
+    ProtocolTest.expectThat(sequentialExecutionSuite.skipCount === 0, "sequentialExecutionSuite should have skipped zero tests.");
 
-    var abortOnFailureSuite = new ProtocolTest.SyncTestSuite("SyncTestSuite.AbortOnFailure");
+    var abortOnFailureSuite = ProtocolTest.createSyncSuite("SyncTestSuite.AbortOnFailure");
     abortOnFailureSuite.addTestCase({
         name: "PassingTest5",
         description: "This test is a dummy.",
@@ -125,11 +132,11 @@
     });
 
     abortOnFailureSuite.runTestCases();
-    ProtocolTest.assert(result === false, "Return value of abortOnFailureSuite.runTestCases() should be false when a test case fails.");
-    ProtocolTest.assert(abortOnFailureSuite.runCount === 2, "abortOnFailureSuite should have executed two tests.");
-    ProtocolTest.assert(abortOnFailureSuite.passCount === 1, "abortOnFailureSuite should have passed one test.");
-    ProtocolTest.assert(abortOnFailureSuite.failCount === 1, "abortOnFailureSuite should have failed one test.");
-    ProtocolTest.assert(abortOnFailureSuite.skipCount === 1, "abortOnFailureSuite should have skipped one test.");
+    ProtocolTest.expectThat(result === false, "Return value of abortOnFailureSuite.runTestCases() should be false when a test case fails.");
+    ProtocolTest.expectThat(abortOnFailureSuite.runCount === 2, "abortOnFailureSuite should have executed two tests.");
+    ProtocolTest.expectThat(abortOnFailureSuite.passCount === 1, "abortOnFailureSuite should have passed one test.");
+    ProtocolTest.expectThat(abortOnFailureSuite.failCount === 1, "abortOnFailureSuite should have failed one test.");
+    ProtocolTest.expectThat(abortOnFailureSuite.skipCount === 1, "abortOnFailureSuite should have skipped one test.");
 
     ProtocolTest.completeTest();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to