From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../tracer/tests/browser/WorkerDebugger.tracer.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 devtools/server/tracer/tests/browser/WorkerDebugger.tracer.js (limited to 'devtools/server/tracer/tests/browser/WorkerDebugger.tracer.js') diff --git a/devtools/server/tracer/tests/browser/WorkerDebugger.tracer.js b/devtools/server/tracer/tests/browser/WorkerDebugger.tracer.js new file mode 100644 index 0000000000..bd6e646b3b --- /dev/null +++ b/devtools/server/tracer/tests/browser/WorkerDebugger.tracer.js @@ -0,0 +1,36 @@ +"use strict"; + +/* global global, loadSubScript */ + +try { + // For some reason WorkerDebuggerGlobalScope.global doesn't expose JS variables + // and we can't call via global.foo(). Instead we have to go throught the Debugger API. + const dbg = new Debugger(global); + const [debuggee] = dbg.getDebuggees(); + + /* global startTracing, stopTracing, addTracingListener, removeTracingListener */ + loadSubScript("resource://devtools/server/tracer/tracer.jsm"); + const frames = []; + const listener = { + onTracingFrame(args) { + frames.push(args); + + // Return true, to also log the trace to stdout + return true; + }, + }; + addTracingListener(listener); + startTracing({ global, prefix: "testWorkerPrefix" }); + + debuggee.executeInGlobal("foo()"); + + stopTracing(); + removeTracingListener(listener); + + // Send the frames to the main thread to do the assertions there. + postMessage(JSON.stringify(frames)); +} catch (e) { + dump( + "Exception while running debugger test script: " + e + "\n" + e.stack + "\n" + ); +} -- cgit v1.2.3