зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 7dddff2d1120 (bug 1612570) for causing mochitest failures on test_promise.html.
CLOSED TREE
This commit is contained in:
Родитель
c0261da5cd
Коммит
897885fdb0
|
@ -368,9 +368,7 @@ bool ExecutionRunnable::ParseAndLinkModule(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecutionRunnable::RunOnWorkletThread() {
|
void ExecutionRunnable::RunOnWorkletThread() {
|
||||||
WorkletThread* workletThread =
|
WorkletThread::EnsureCycleCollectedJSContext(mParentRuntime);
|
||||||
static_cast<WorkletThread*>(NS_GetCurrentThread());
|
|
||||||
workletThread->EnsureCycleCollectedJSContext(mParentRuntime);
|
|
||||||
|
|
||||||
WorkletGlobalScope* globalScope = mWorkletImpl->GetGlobalScope();
|
WorkletGlobalScope* globalScope = mWorkletImpl->GetGlobalScope();
|
||||||
MOZ_ASSERT(globalScope);
|
MOZ_ASSERT(globalScope);
|
||||||
|
|
|
@ -305,33 +305,7 @@ WorkletThread::DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t aFlags) {
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool DispatchToEventLoop(void* aClosure,
|
/* static */
|
||||||
JS::Dispatchable* aDispatchable) {
|
|
||||||
// This callback may execute either on the worklet thread or a random
|
|
||||||
// JS-internal helper thread.
|
|
||||||
|
|
||||||
// See comment at JS::InitDispatchToEventLoop() below for how we know the
|
|
||||||
// WorkletThread is alive.
|
|
||||||
WorkletThread* workletThread = reinterpret_cast<WorkletThread*>(aClosure);
|
|
||||||
|
|
||||||
nsresult rv = workletThread->DispatchRunnable(NS_NewRunnableFunction(
|
|
||||||
"WorkletThread::DispatchToEventLoop", [aDispatchable]() {
|
|
||||||
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
|
|
||||||
if (!ccjscx) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkletJSContext* wjc = ccjscx->GetAsWorkletJSContext();
|
|
||||||
if (!wjc) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
aDispatchable->run(wjc->Context(), JS::Dispatchable::NotShuttingDown);
|
|
||||||
}));
|
|
||||||
|
|
||||||
return NS_SUCCEEDED(rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorkletThread::EnsureCycleCollectedJSContext(JSRuntime* aParentRuntime) {
|
void WorkletThread::EnsureCycleCollectedJSContext(JSRuntime* aParentRuntime) {
|
||||||
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
|
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
|
||||||
if (ccjscx) {
|
if (ccjscx) {
|
||||||
|
@ -354,11 +328,6 @@ void WorkletThread::EnsureCycleCollectedJSContext(JSRuntime* aParentRuntime) {
|
||||||
// FIXME: JS::SetCTypesActivityCallback
|
// FIXME: JS::SetCTypesActivityCallback
|
||||||
// FIXME: JS_SetGCZeal
|
// FIXME: JS_SetGCZeal
|
||||||
|
|
||||||
// A WorkletThread lives strictly longer than its JSRuntime so we can safely
|
|
||||||
// store a raw pointer as the callback's closure argument on the JSRuntime.
|
|
||||||
JS::InitDispatchToEventLoop(context->Context(), DispatchToEventLoop,
|
|
||||||
(void*)this);
|
|
||||||
|
|
||||||
JS_SetNativeStackQuota(context->Context(),
|
JS_SetNativeStackQuota(context->Context(),
|
||||||
WORKLET_CONTEXT_NATIVE_STACK_LIMIT);
|
WORKLET_CONTEXT_NATIVE_STACK_LIMIT);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class WorkletThread final : public nsThread, public nsIObserver {
|
||||||
// Threads that call EnsureCycleCollectedJSContext must call
|
// Threads that call EnsureCycleCollectedJSContext must call
|
||||||
// DeleteCycleCollectedJSContext::Get() before terminating. Clients of
|
// DeleteCycleCollectedJSContext::Get() before terminating. Clients of
|
||||||
// Create() do not need to do this as Terminate() will ensure this happens.
|
// Create() do not need to do this as Terminate() will ensure this happens.
|
||||||
void EnsureCycleCollectedJSContext(JSRuntime* aParentRuntime);
|
static void EnsureCycleCollectedJSContext(JSRuntime* aParentRuntime);
|
||||||
static void DeleteCycleCollectedJSContext();
|
static void DeleteCycleCollectedJSContext();
|
||||||
|
|
||||||
static bool IsOnWorkletThread();
|
static bool IsOnWorkletThread();
|
||||||
|
|
|
@ -23,5 +23,3 @@ support-files=worklet_exception.js
|
||||||
[test_paintWorklet.html]
|
[test_paintWorklet.html]
|
||||||
scheme = http
|
scheme = http
|
||||||
support-files=worklet_paintWorklet.js
|
support-files=worklet_paintWorklet.js
|
||||||
[test_promise.html]
|
|
||||||
support-files=worklet_promise.js
|
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
<!DOCTYPE HTML>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Test for promise in worklet</title>
|
|
||||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
||||||
<script type="application/javascript" src="common.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<script type="application/javascript">
|
|
||||||
|
|
||||||
function configureTest() {
|
|
||||||
return SpecialPowers.pushPrefEnv(
|
|
||||||
{"set": [["dom.audioworklet.enabled", true],
|
|
||||||
["dom.worklet.enabled", true]]});
|
|
||||||
}
|
|
||||||
|
|
||||||
function runTestInIframe() {
|
|
||||||
if (!SpecialPowers.Cu.getJSTestingFunctions().wasmIsSupported()) {
|
|
||||||
SimpleTest.finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok(window.isSecureContext, "Test should run in secure context");
|
|
||||||
var audioContext = new AudioContext();
|
|
||||||
ok(audioContext.audioWorklet instanceof AudioWorklet,
|
|
||||||
"AudioContext.audioWorklet should be an instance of AudioWorklet");
|
|
||||||
audioContext.audioWorklet.addModule("worklet_promise.js")
|
|
||||||
.then(() => {
|
|
||||||
const node = new AudioWorkletNode(audioContext, 'promise');
|
|
||||||
node.port.onmessage = e => {
|
|
||||||
ok(e.data instanceof WebAssembly.Module, "The WasmModule has been compiled into the worklet.");
|
|
||||||
SimpleTest.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary);
|
|
||||||
const fooModuleCode = wasmTextToBinary(`(module
|
|
||||||
(func $foo (result i32) (i32.const 42))
|
|
||||||
(export "foo" $foo)
|
|
||||||
)`);
|
|
||||||
|
|
||||||
node.port.postMessage(fooModuleCode);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,22 +0,0 @@
|
||||||
class WasmProcessWorkletProcessor extends AudioWorkletProcessor {
|
|
||||||
constructor(...args) {
|
|
||||||
super(...args);
|
|
||||||
this.port.onmessage = e => {
|
|
||||||
WebAssembly.compile(e.data).then(
|
|
||||||
m => {
|
|
||||||
this.port.postMessage(m);
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.port.postMessage("error");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
process(inputs, outputs, parameters) {
|
|
||||||
// Do nothing, output silence
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
registerProcessor("promise", WasmProcessWorkletProcessor);
|
|
Загрузка…
Ссылка в новой задаче