Index: third_party/WebKit/LayoutTests/inspector-protocol/worker/worker-console.html |
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/worker/worker-console.html b/third_party/WebKit/LayoutTests/inspector-protocol/worker/worker-console.html |
deleted file mode 100644 |
index 51ac7afd4f6991a3821dde62f396255a498ffade..0000000000000000000000000000000000000000 |
--- a/third_party/WebKit/LayoutTests/inspector-protocol/worker/worker-console.html |
+++ /dev/null |
@@ -1,289 +0,0 @@ |
-<html> |
-<head> |
-<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script> |
-<script> |
- |
-var worker; |
-var onMessageCallbacks = {}; |
- |
-function startWorker() |
-{ |
- var callback; |
- var promise = new Promise((fulfill) => callback = fulfill); |
- worker = new Worker("../resources/worker-console-worker.js"); |
- worker.onmessage = function(event) { |
- worker.onmessage = onMessageFromWorker; |
- callback(); |
- }; |
- return promise; |
-} |
- |
-function logInWorkerFromPage(message, callback) |
-{ |
- onMessageCallbacks[message] = callback; |
- worker.postMessage(message); |
-} |
- |
-function onMessageFromWorker(event) |
-{ |
- var callback = onMessageCallbacks[event.data]; |
- delete onMessageCallbacks[event.data]; |
- if (callback) |
- callback(); |
-} |
- |
-function stopWorker() |
-{ |
- worker.terminate(); |
- worker = null; |
-} |
- |
-function test() |
-{ |
- var workerEventHandler = {}; |
- InspectorTest.eventHandler["Target.attachedToTarget"] = onWorkerCreated; |
- InspectorTest.eventHandler["Target.receivedMessageFromTarget"] = onWorkerMessage; |
- workerEventHandler["Runtime.consoleAPICalled"] = onConsoleAPICalledFromWorker; |
- |
- var workerId; |
- |
- function onWorkerCreated(payload) |
- { |
- InspectorTest.log("Worker.created"); |
- workerId = payload.params.targetInfo.targetId; |
- } |
- |
- var requestId = 0; |
- var dispatchTable = []; |
- |
- function sendCommandToWorker(method, params, callback) |
- { |
- dispatchTable[++requestId] = callback; |
- var messageObject = { |
- "method": method, |
- "params": params, |
- "id": requestId |
- }; |
- InspectorTest.sendCommandOrDie("Target.sendMessageToTarget", { |
- targetId: workerId, |
- message: JSON.stringify(messageObject) |
- }); |
- } |
- |
- function onWorkerMessage(payload) |
- { |
- if (payload.params.targetId !== workerId) |
- InspectorTest.log("targetId mismatch"); |
- var messageObject = JSON.parse(payload.params.message); |
- var messageId = messageObject["id"]; |
- if (typeof messageId === "number") { |
- var handler = dispatchTable[messageId]; |
- dispatchTable[messageId] = null; |
- if (handler && typeof handler === "function") |
- handler(messageObject); |
- } else { |
- var eventName = messageObject["method"]; |
- var eventHandler = workerEventHandler[eventName]; |
- if (eventHandler) |
- eventHandler(messageObject); |
- } |
- } |
- |
- function logInWorker(message, next) |
- { |
- InspectorTest.log("Logging in worker: " + message); |
- InspectorTest.eventHandler["Log.entryAdded"] = onLogEntry; |
- InspectorTest.evaluateInPage("logInWorkerFromPage(\"" + message + "\")"); |
- |
- function onLogEntry(payload) |
- { |
- InspectorTest.log("Got log message from page: " + payload.params.entry.text); |
- delete InspectorTest.eventHandler["Log.entryAdded"]; |
- next(); |
- } |
- } |
- |
- var gotMessages = []; |
- var waitingForMessage; |
- var waitingForMessageCallback; |
- |
- function onConsoleAPICalledFromWorker(payload) |
- { |
- var message = payload.params.args[0].value; |
- InspectorTest.log("Got console API call from worker: " + message); |
- gotMessages.push(message); |
- if (message === waitingForMessage) |
- waitingForMessageCallback(); |
- } |
- |
- function waitForMessage(message, next) |
- { |
- if (gotMessages.indexOf(message) !== -1) { |
- next(); |
- return; |
- } |
- waitingForMessage = message; |
- waitingForMessageCallback = next; |
- } |
- |
- var steps = [ |
- function listenToConsole(next) |
- { |
- InspectorTest.sendCommandOrDie("Log.enable", {}, next); |
- }, |
- |
- function start0(next) |
- { |
- InspectorTest.log("Starting worker"); |
- InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
- }, |
- |
- function log0(next) |
- { |
- logInWorker("message0", next); |
- }, |
- |
- function stop0(next) |
- { |
- InspectorTest.log("Stopping worker"); |
- InspectorTest.evaluateInPage("stopWorker()", next); |
- }, |
- |
- function start1(next) |
- { |
- InspectorTest.log("Starting worker"); |
- InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
- }, |
- |
- function log1(next) |
- { |
- logInWorker("message1", next); |
- }, |
- |
- function enable1(next) |
- { |
- InspectorTest.log("Starting autoattach"); |
- InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: true, waitForDebuggerOnStart: false}, next); |
- }, |
- |
- function consoleEnable1(next) |
- { |
- InspectorTest.log("Sending Runtime.enable to worker"); |
- waitForMessage("message1", next); |
- sendCommandToWorker("Runtime.enable", {}); |
- }, |
- |
- function log2(next) |
- { |
- logInWorker("message2", next); |
- }, |
- |
- function waitForMessage2(next) |
- { |
- waitForMessage("message2", next); |
- }, |
- |
- function throw1(next) |
- { |
- logInWorker("throw1", next); |
- }, |
- |
- function disable1(next) |
- { |
- InspectorTest.log("Stopping autoattach"); |
- InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: false, waitForDebuggerOnStart: false}, next); |
- }, |
- |
- function log3(next) |
- { |
- logInWorker("message3", next); |
- }, |
- |
- function stop1(next) |
- { |
- InspectorTest.log("Stopping worker"); |
- InspectorTest.evaluateInPage("stopWorker()", next); |
- }, |
- |
- |
- function enable2(next) |
- { |
- InspectorTest.log("Starting autoattach"); |
- InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: true, waitForDebuggerOnStart: false}, next); |
- }, |
- |
- function start2(next) |
- { |
- InspectorTest.log("Starting worker"); |
- InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
- }, |
- |
- function log4(next) |
- { |
- logInWorker("message4", next); |
- }, |
- |
- function consoleEnable2(next) |
- { |
- InspectorTest.log("Sending Runtime.enable to worker"); |
- waitForMessage("message4", next); |
- sendCommandToWorker("Runtime.enable", {}); |
- }, |
- |
- function log5(next) |
- { |
- logInWorker("message5", next); |
- }, |
- |
- function waitForMessage5(next) |
- { |
- waitForMessage("message5", next); |
- }, |
- |
- function stop2(next) |
- { |
- InspectorTest.log("Stopping worker"); |
- InspectorTest.evaluateInPage("stopWorker()", next); |
- }, |
- |
- function start3(next) |
- { |
- InspectorTest.log("Starting worker"); |
- InspectorTest.evaluateInPageAsync("startWorker()").then(next); |
- }, |
- |
- function log6(next) |
- { |
- logInWorker("message6", next); |
- }, |
- |
- function stop3(next) |
- { |
- InspectorTest.log("Stopping worker"); |
- InspectorTest.evaluateInPage("stopWorker()", next); |
- }, |
- |
- function disable2(next) |
- { |
- InspectorTest.log("Stopping autoattach"); |
- InspectorTest.sendCommandOrDie("Target.setAutoAttach", {autoAttach: false, waitForDebuggerOnStart: false}, next); |
- } |
- ]; |
- |
- function runNextStep() |
- { |
- if (!steps.length) { |
- InspectorTest.completeTest(); |
- return; |
- } |
- var nextStep = steps.shift(); |
- InspectorTest.safeWrap(nextStep)(runNextStep); |
- } |
- |
- runNextStep(); |
-} |
-</script> |
-</head> |
-<body onload="runTest()"> |
-</body> |
-</html> |