3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/timeline-test.js"></script>
5 <script src=
"../tracing-test.js"></script>
8 // Save references to the worker objects to make sure they are not GC'ed.
12 function startWorkerAndRunTest()
14 worker1
= new Worker("resources/worker.js");
15 worker1
.postMessage("");
17 if (window
.testRunner
) {
18 testRunner
.dumpAsText();
19 testRunner
.waitUntilDone();
22 worker1
.onmessage = function(event
)
24 worker1
.onmessage
= null;
29 function startSecondWorker(onActionComplete
)
31 worker2
= new Worker("resources/worker.js");
32 worker2
.postMessage("");
33 worker2
.onmessage = function(event
)
36 worker2
.onmessage
= null;
42 InspectorTest
.invokeWithTracing("startSecondWorker", InspectorTest
.safeWrap(processTracingEvents
));
44 var workerMetadataEventCount
= 0;
45 function processTracingEvents()
47 InspectorTest
.tracingModel().sortedProcesses().forEach(function(process
) {
48 process
.sortedThreads().forEach(function(thread
) {
49 thread
.events().forEach(processEvent
);
52 InspectorTest
.assertEquals(2, workerMetadataEventCount
);
53 InspectorTest
.completeTest();
56 function processEvent(event
)
58 if (!event
.hasCategory(WebInspector
.TracingModel
.DevToolsMetadataEventCategory
) || event
.name
!== WebInspector
.TimelineModel
.DevToolsMetadataEvent
.TracingSessionIdForWorker
)
61 ++workerMetadataEventCount
;
62 InspectorTest
.assertEquals(InspectorTest
.tracingTimelineModel().sessionId(), event
.args
["data"]["sessionId"]);
63 InspectorTest
.addResult("Got DevTools worker metadata event(" + workerMetadataEventCount
+ "): " + event
.name
);
71 <body onload=
"startWorkerAndRunTest()">
73 Tests that worker events are recorded with proper devtools metadata events.