| Index: LayoutTests/http/tests/inspector-protocol/inspector-protocol-test.js
|
| diff --git a/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js b/LayoutTests/http/tests/inspector-protocol/inspector-protocol-test.js
|
| similarity index 72%
|
| rename from LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js
|
| rename to LayoutTests/http/tests/inspector-protocol/inspector-protocol-test.js
|
| index c650ea176ea455b00c7668c6bd4e819417de2f2c..24d460e403ba003799ffa6782f1daccedf98c31b 100644
|
| --- a/LayoutTests/http/tests/inspector-protocol/resources/InspectorTest.js
|
| +++ b/LayoutTests/http/tests/inspector-protocol/inspector-protocol-test.js
|
| @@ -23,6 +23,9 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
| * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| +
|
| +var initialize_InspectorTest = function() {
|
| +
|
| InspectorFrontendAPI = {};
|
|
|
| InspectorTest = {};
|
| @@ -165,7 +168,7 @@ InspectorTest.logObject = function(object, title)
|
|
|
| /**
|
| * Logs message directly to process stdout via alert function (hopefully followed by flush call).
|
| -* This message should survive process crash or kill by timeout.
|
| +* This message should survive process crash or kill by timeout.
|
| * @param {string} message
|
| */
|
| InspectorTest.debugLog = function(message)
|
| @@ -228,12 +231,94 @@ InspectorTest.importScript = function(scriptName)
|
| window.eval(xhr.responseText + "\n//@ sourceURL=" + scriptName);
|
| }
|
|
|
| -window.addEventListener("message", function(event) {
|
| - try {
|
| - eval(event.data);
|
| - } catch (e) {
|
| - alert(e.stack);
|
| - InspectorTest.completeTest();
|
| - throw e;
|
| +};
|
| +
|
| +var outputElement;
|
| +
|
| +/**
|
| + * Logs message to process stdout via alert (hopefully implemented with immediate flush).
|
| + * @param {string} text
|
| + */
|
| +function debugLog(text)
|
| +{
|
| + alert(text);
|
| +}
|
| +
|
| +/**
|
| + * @param {string} text
|
| + */
|
| +function log(text)
|
| +{
|
| + if (!outputElement) {
|
| + var intermediate = document.createElement("div");
|
| + document.body.appendChild(intermediate);
|
| +
|
| + var intermediate2 = document.createElement("div");
|
| + intermediate.appendChild(intermediate2);
|
| +
|
| + outputElement = document.createElement("div");
|
| + outputElement.className = "output";
|
| + outputElement.id = "output";
|
| + outputElement.style.whiteSpace = "pre";
|
| + intermediate2.appendChild(outputElement);
|
| + }
|
| + outputElement.appendChild(document.createTextNode(text));
|
| + outputElement.appendChild(document.createElement("br"));
|
| +}
|
| +
|
| +function closeTest()
|
| +{
|
| + closeInspector();
|
| + testRunner.notifyDone();
|
| +}
|
| +
|
| +function runTest()
|
| +{
|
| + if (!window.testRunner) {
|
| + console.error("This test requires DumpRenderTree");
|
| + return;
|
| + }
|
| + testRunner.dumpAsText();
|
| + testRunner.waitUntilDone();
|
| + testRunner.setCanOpenWindows(true);
|
| +
|
| + openInspector();
|
| +}
|
| +
|
| +function closeInspector()
|
| +{
|
| + window.internals.closeDummyInspectorFrontend();
|
| +}
|
| +
|
| +function openInspector()
|
| +{
|
| + var scriptTags = document.getElementsByTagName("script");
|
| + var scriptUrlBasePath = "";
|
| + for (var i = 0; i < scriptTags.length; ++i) {
|
| + var index = scriptTags[i].src.lastIndexOf("/inspector-protocol-test.js");
|
| + if (index > -1 ) {
|
| + scriptUrlBasePath = scriptTags[i].src.slice(0, index);
|
| + break;
|
| + }
|
| }
|
| -});
|
| +
|
| + var dummyFrontendURL = scriptUrlBasePath + "/resources/protocol-test.html";
|
| + var inspectorFrontend = window.internals.openDummyInspectorFrontend(dummyFrontendURL);
|
| + inspectorFrontend.addEventListener("load", function(event) {
|
| + // FIXME: rename this 'test' global field across all tests.
|
| + var testFunction = window.test;
|
| + if (typeof testFunction === "function") {
|
| + var initializers = "";
|
| + for (var symbol in window) {
|
| + if (!/^initialize_/.test(symbol) || typeof window[symbol] !== "function")
|
| + continue;
|
| + initializers += "(" + window[symbol].toString() + ")();\n";
|
| + }
|
| + inspectorFrontend.postMessage(initializers + "(" + testFunction.toString() +")();", "*");
|
| + return;
|
| + }
|
| + // Kill waiting process if failed to send.
|
| + alert("Failed to send test function");
|
| + testRunner.notifyDone();
|
| + });
|
| +}
|
|
|