Skip to content

Commit

Permalink
Fix web test for SAB devtools issue
Browse files Browse the repository at this point in the history
The SharedArrayBuffer constructor is not exposed anymore in non
cross-origin-isolated contexts. Trying to use it throws, instead of
raising a warning. For creating a SharedArrayBuffer and testing the
devtools issue, we need to use the trick from
whatwg/html#5380.

Bug: 1194226
Change-Id: I622e5857af4de89e726aadc3731bc5a0df0e91f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2843329
Commit-Queue: Antonio Sartori <[email protected]>
Reviewed-by: Sigurd Schneider <[email protected]>
Cr-Commit-Position: refs/heads/master@{#875074}
  • Loading branch information
antosart authored and Chromium LUCI CQ committed Apr 22, 2021
1 parent 7ba67e5 commit 5bbe2a3
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 7 deletions.
2 changes: 0 additions & 2 deletions third_party/blink/web_tests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -4989,8 +4989,6 @@ crbug.com/1194557 http/tests/devtools/local-object-properties-section.js [ Failu
crbug.com/1194557 http/tests/devtools/application-panel/resources-panel-resource-preview.js [ Failure Timeout ]
crbug.com/1194557 http/tests/devtools/sources/debugger-breakpoints/set-breakpoint-while-blocking-main-thread.js [ Failure Timeout ]
crbug.com/1194557 http/tests/devtools/unit/object-properties-expand-recursively.js [ Failure Timeout ]
crbug.com/1194557 http/tests/inspector-protocol/issues/sab-creation-issue.js [ Failure Timeout ]
crbug.com/1194557 http/tests/inspector-protocol/issues/sab-postMessage-issue.js [ Failure Timeout ]
crbug.com/1194557 http/tests/websocket/send-arraybufferview.html [ Failure Timeout ]
crbug.com/1194557 storage/indexeddb/shared-array-buffer-throws.html [ Failure Timeout ]
crbug.com/1194557 virtual/shared_array_buffer_on_desktop/external/wpt/html/browsers/origin/origin-keyed-agent-clusters/iframe-navigation/parent-no-1-subdomain-yes-2-subdomain2-no.sub.https.html [ Failure Timeout ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Inspector issue: {
sharedArrayBufferIssueDetails : {
isWarning : true
sourceCodeLocation : {
columnNumber : 9
columnNumber : 14
lineNumber : 0
scriptId : <string>
url :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
`Verifies that creating a SAB in a non-COI context causes an issue.\n`);

await dp.Audits.enable();
session.evaluate(`var x = new SharedArrayBuffer();`);
session.evaluate(
`var x = new (new WebAssembly.Memory(
{ shared:true, initial:0, maximum:0 }).buffer.constructor)();`);
const issue = await dp.Audits.onceIssueAdded();

testRunner.log(issue.params, 'Inspector issue: ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Creation issue: {
sharedArrayBufferIssueDetails : {
isWarning : true
sourceCodeLocation : {
columnNumber : 13
columnNumber : 18
lineNumber : 0
scriptId : <string>
url :
Expand All @@ -22,7 +22,7 @@ Transfer issue: {
code : SharedArrayBufferIssue
details : {
sharedArrayBufferIssueDetails : {
isWarning : true
isWarning : false
sourceCodeLocation : {
columnNumber : 1
lineNumber : 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
`Verifies that post-messaging a SAB causes an issue.\n`);

await dp.Audits.enable();
session.evaluate(`postMessage(new SharedArrayBuffer());`);
session.evaluate(`postMessage(new (new WebAssembly.Memory(
{ shared:true, initial:0, maximum:0 }).buffer.constructor)());`);
const issues = await Promise.all(
[dp.Audits.onceIssueAdded(), dp.Audits.onceIssueAdded()]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Verifies that post-messaging a SAB causes an issue.

Creation issue: {
issue : {
code : SharedArrayBufferIssue
details : {
sharedArrayBufferIssueDetails : {
isWarning : true
sourceCodeLocation : {
columnNumber : 18
lineNumber : 0
scriptId : <string>
url :
}
type : CreationIssue
}
}
}
}
Transfer issue: {
issue : {
code : SharedArrayBufferIssue
details : {
sharedArrayBufferIssueDetails : {
isWarning : true
sourceCodeLocation : {
columnNumber : 1
lineNumber : 0
scriptId : <string>
url :
}
type : TransferIssue
}
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Verifies that post-messaging a SAB causes an issue.

Creation issue: {
issue : {
code : SharedArrayBufferIssue
details : {
sharedArrayBufferIssueDetails : {
isWarning : true
sourceCodeLocation : {
columnNumber : 18
lineNumber : 0
scriptId : <string>
url :
}
type : CreationIssue
}
}
}
}
Transfer issue: {
issue : {
code : SharedArrayBufferIssue
details : {
sharedArrayBufferIssueDetails : {
isWarning : true
sourceCodeLocation : {
columnNumber : 1
lineNumber : 0
scriptId : <string>
url :
}
type : TransferIssue
}
}
}
}

0 comments on commit 5bbe2a3

Please sign in to comment.