Commit 0366e7e4 authored by Andrey Lushnikov's avatar Andrey Lushnikov Committed by Commit Bot

DevTools: mark execution contexts as isolated worlds

This patch adds the `isIsolatedWorld` bit to the execution context's
aux data.

This is necessary to be able to differentiate between isolated worlds
and other worlds, e.g. worklets.

R=dgozman

Change-Id: I3741b1631f653ffcfaddcba6bf40b229711494dc
Reviewed-on: https://chromium-review.googlesource.com/1173015
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583153}
parent 42dcb573
...@@ -6,6 +6,7 @@ Tests that execution contexts are reported for iframes that don't have src attri ...@@ -6,6 +6,7 @@ Tests that execution contexts are reported for iframes that don't have src attri
auxData : { auxData : {
frameId : <string> frameId : <string>
isDefault : true isDefault : true
type : default
} }
id : <number> id : <number>
name : name :
...@@ -21,6 +22,7 @@ Tests that execution contexts are reported for iframes that don't have src attri ...@@ -21,6 +22,7 @@ Tests that execution contexts are reported for iframes that don't have src attri
auxData : { auxData : {
frameId : <string> frameId : <string>
isDefault : true isDefault : true
type : default
} }
id : <number> id : <number>
name : name :
......
...@@ -6,6 +6,7 @@ Tests that execution contexts are reported for frames that were blocked due to m ...@@ -6,6 +6,7 @@ Tests that execution contexts are reported for frames that were blocked due to m
auxData : { auxData : {
frameId : <string> frameId : <string>
isDefault : true isDefault : true
type : default
} }
id : <number> id : <number>
name : name :
...@@ -21,6 +22,7 @@ Tests that execution contexts are reported for frames that were blocked due to m ...@@ -21,6 +22,7 @@ Tests that execution contexts are reported for frames that were blocked due to m
auxData : { auxData : {
frameId : <string> frameId : <string>
isDefault : true isDefault : true
type : default
} }
id : <number> id : <number>
name : name :
......
...@@ -6,6 +6,7 @@ Tests that execution contexts are reported for frames that were blocked due to m ...@@ -6,6 +6,7 @@ Tests that execution contexts are reported for frames that were blocked due to m
auxData : { auxData : {
frameId : <string> frameId : <string>
isDefault : true isDefault : true
type : default
} }
id : <number> id : <number>
name : name :
...@@ -21,6 +22,7 @@ Tests that execution contexts are reported for frames that were blocked due to m ...@@ -21,6 +22,7 @@ Tests that execution contexts are reported for frames that were blocked due to m
auxData : { auxData : {
frameId : <string> frameId : <string>
isDefault : true isDefault : true
type : default
} }
id : <number> id : <number>
name : name :
......
...@@ -3,4 +3,5 @@ Runtime enabled ...@@ -3,4 +3,5 @@ Runtime enabled
Page enabled Page enabled
Main Frame obtained Main Frame obtained
PASS - execution context id match. PASS - execution context id match.
PASS - reported as isolated world.
(async function(testRunner) { (async function(testRunner) {
var {page, session, dp} = await testRunner.startBlank('Tests Page.createIsolatedWorld method.'); const {page, session, dp} = await testRunner.startBlank('Tests Page.createIsolatedWorld method.');
var reportedExecutionContextId; let reportedExecutionContextId;
let isIsolatedWorld = false;
dp.Runtime.onExecutionContextCreated(message => { dp.Runtime.onExecutionContextCreated(message => {
if (message.params.context.auxData.frameId !== mainFrameId) if (message.params.context.auxData.frameId !== mainFrameId)
return; return;
if (message.params.context.auxData.isDefault === false && if (message.params.context.auxData.isDefault === false &&
message.params.context.name === 'Test world') { message.params.context.name === 'Test world') {
reportedExecutionContextId = message.params.context.id; reportedExecutionContextId = message.params.context.id;
isIsolatedWorld = message.params.context.auxData.type === 'isolated';
} else { } else {
testRunner.log('fail - main world created.'); testRunner.log('fail - main world created.');
testRunner.log(JSON.stringify(message.params)); testRunner.log(JSON.stringify(message.params));
...@@ -30,5 +32,9 @@ ...@@ -30,5 +32,9 @@
testRunner.log('PASS - execution context id match.'); testRunner.log('PASS - execution context id match.');
else else
testRunner.log('fail - execution context id differ.'); testRunner.log('fail - execution context id differ.');
if (isIsolatedWorld)
testRunner.log('PASS - reported as isolated world.');
else
testRunner.log('fail - reported as non-isolated world.');
testRunner.completeTest(); testRunner.completeTest();
}) })
...@@ -140,6 +140,12 @@ void MainThreadDebugger::ContextCreated(ScriptState* script_state, ...@@ -140,6 +140,12 @@ void MainThreadDebugger::ContextCreated(ScriptState* script_state,
StringBuilder aux_data_builder; StringBuilder aux_data_builder;
aux_data_builder.Append("{\"isDefault\":"); aux_data_builder.Append("{\"isDefault\":");
aux_data_builder.Append(world.IsMainWorld() ? "true" : "false"); aux_data_builder.Append(world.IsMainWorld() ? "true" : "false");
if (world.IsMainWorld())
aux_data_builder.Append(",\"type\":\"default\"");
else if (world.IsIsolatedWorld())
aux_data_builder.Append(",\"type\":\"isolated\"");
else if (world.IsWorkerWorld())
aux_data_builder.Append(",\"type\":\"worker\"");
aux_data_builder.Append(",\"frameId\":\""); aux_data_builder.Append(",\"frameId\":\"");
aux_data_builder.Append(IdentifiersFactory::FrameId(frame)); aux_data_builder.Append(IdentifiersFactory::FrameId(frame));
aux_data_builder.Append("\"}"); aux_data_builder.Append("\"}");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment