Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/worker/exception-from-worker-contains-stack.js

Issue 2942573003: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: Protocol -> dp Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector-protocol/worker/exception-from-worker-contains-stack.js
diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/worker/exception-from-worker-contains-stack.js b/third_party/WebKit/LayoutTests/inspector-protocol/worker/exception-from-worker-contains-stack.js
new file mode 100644
index 0000000000000000000000000000000000000000..37b6fa13618bb93cfff8f77fa558a42acb31eee8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/worker/exception-from-worker-contains-stack.js
@@ -0,0 +1,51 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.startBlank('Tests that console message from worker contains stack trace.');
+
+ var workerRequestId = 1;
+ function sendCommandToWorker(method, params, workerId) {
+ dp.Target.sendMessageToTarget({
+ targetId: workerId,
+ message: JSON.stringify({ method: method, params: params, id: workerRequestId++ })
+ });
+ }
+
+ var waitForWorkers = 2;
+ dp.Target.onAttachedToTarget(messageObject => {
+ var workerId = messageObject['params']['targetInfo']['targetId'];
+ testRunner.log('Worker created');
+ sendCommandToWorker('Runtime.enable', {}, workerId);
+ if (!--waitForWorkers)
+ session.evaluate('worker1.postMessage(239);worker2.postMessage(42);');
+ });
+
+ var workerTerminated = false;
+ var messageReceived = false;
+ dp.Target.onReceivedMessageFromTarget(messageObject => {
+ var message = JSON.parse(messageObject['params']['message']);
+ if (message['method'] === 'Runtime.exceptionThrown') {
+ var callFrames = message.params.exceptionDetails.stackTrace ? message.params.exceptionDetails.stackTrace.callFrames : [];
+ testRunner.log(callFrames.length > 0 ? 'Message with stack trace received.' : '[FAIL] Message contains empty stack trace');
+ messageReceived = true;
+ if (messageReceived && workerTerminated)
+ testRunner.completeTest();
+ }
+ });
+
+ function onDetached(messageObject) {
+ dp.Target.offDetachedFromTarget(onDetached);
+ workerTerminated = true;
+ if (messageReceived && workerTerminated)
+ testRunner.completeTest();
+ }
+ dp.Target.onDetachedFromTarget(onDetached);
+
+ await dp.Target.setAutoAttach({autoAttach: true, waitForDebuggerOnStart: false});
+ session.evaluate(`
+ window.worker1 = new Worker('${testRunner.url('../resources/worker-with-throw.js')}');
+ window.worker1.onerror = function(e) {
+ e.preventDefault();
+ worker1.terminate();
+ }
+ window.worker2 = new Worker('${testRunner.url('../resources/worker-with-throw.js')}');
+ `);
+})

Powered by Google App Engine
This is Rietveld 408576698