eb722a0408
Drive-by fix to align what builds the test runner considers to be able to have shared memory features and what builds can create a shared Isolate. Bug: v8:12007 Change-Id: I151513ccbfbee31e5b35c5ce8e9192732eabfee2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3421507 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/main@{#78824}
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
// Copyright 2021 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
// Flags: --shared-string-table --allow-natives-syntax
|
|
|
|
if (this.Worker) {
|
|
|
|
(function TestSharedStringPostMessage() {
|
|
let workerScript =
|
|
`postMessage("started");
|
|
onmessage = function(str) {
|
|
if (!%IsSharedString(str)) {
|
|
throw new Error("str isn't shared");
|
|
}
|
|
postMessage(str);
|
|
};`;
|
|
|
|
let worker = new Worker(workerScript, { type: 'string' });
|
|
let started = worker.getMessage();
|
|
assertTrue(%IsSharedString(started));
|
|
assertEquals("started", started);
|
|
|
|
// The string literal appears in source and is internalized, so should
|
|
// already be shared.
|
|
let str_to_send = 'foo';
|
|
assertTrue(%IsSharedString(str_to_send));
|
|
worker.postMessage(str_to_send);
|
|
let str_received = worker.getMessage();
|
|
assertTrue(%IsSharedString(str_received));
|
|
// Object.is and === won't check pointer equality of Strings.
|
|
assertTrue(%IsSameHeapObject(str_to_send, str_received));
|
|
|
|
worker.terminate();
|
|
})();
|
|
|
|
}
|