Backed out changeset 7dddff2d1120 (bug 1612570) for causing mochitest failures on test_promise.html.

CLOSED TREE
This commit is contained in:
Arthur Iakab 2020-02-03 10:27:47 +02:00
Родитель c0261da5cd
Коммит 897885fdb0
6 изменённых файлов: 3 добавлений и 108 удалений

Просмотреть файл

@ -368,9 +368,7 @@ bool ExecutionRunnable::ParseAndLinkModule(
}
void ExecutionRunnable::RunOnWorkletThread() {
WorkletThread* workletThread =
static_cast<WorkletThread*>(NS_GetCurrentThread());
workletThread->EnsureCycleCollectedJSContext(mParentRuntime);
WorkletThread::EnsureCycleCollectedJSContext(mParentRuntime);
WorkletGlobalScope* globalScope = mWorkletImpl->GetGlobalScope();
MOZ_ASSERT(globalScope);

Просмотреть файл

@ -305,33 +305,7 @@ WorkletThread::DelayedDispatch(already_AddRefed<nsIRunnable>, uint32_t aFlags) {
return NS_ERROR_NOT_IMPLEMENTED;
}
static bool DispatchToEventLoop(void* aClosure,
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);
}
/* static */
void WorkletThread::EnsureCycleCollectedJSContext(JSRuntime* aParentRuntime) {
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
if (ccjscx) {
@ -354,11 +328,6 @@ void WorkletThread::EnsureCycleCollectedJSContext(JSRuntime* aParentRuntime) {
// FIXME: JS::SetCTypesActivityCallback
// 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(),
WORKLET_CONTEXT_NATIVE_STACK_LIMIT);

Просмотреть файл

@ -29,7 +29,7 @@ class WorkletThread final : public nsThread, public nsIObserver {
// Threads that call EnsureCycleCollectedJSContext must call
// DeleteCycleCollectedJSContext::Get() before terminating. Clients of
// 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 bool IsOnWorkletThread();

Просмотреть файл

@ -23,5 +23,3 @@ support-files=worklet_exception.js
[test_paintWorklet.html]
scheme = http
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);