Backed out 9 changesets (bug 1578623) for causing Windows build bustages CLOSED TREE

Backed out changeset 52a86c60c866 (bug 1578623)
Backed out changeset e4fddd3d24b4 (bug 1578623)
Backed out changeset 65a7c4daec27 (bug 1578623)
Backed out changeset 3badf9215788 (bug 1578623)
Backed out changeset 71e58ee8f684 (bug 1578623)
Backed out changeset 0128e12a910f (bug 1578623)
Backed out changeset 8242877392bd (bug 1578623)
Backed out changeset 6d7be8a22f8b (bug 1578623)
Backed out changeset 3be609a9be36 (bug 1578623)

--HG--
extra : amend_source : b76d374926d247982773b58d12cb26e33d9972e8
This commit is contained in:
Noemi Erli 2019-09-09 03:37:09 +03:00
parent 2a772f968e
commit d988a687b9
18 changed files with 59 additions and 206 deletions

View file

@ -149,9 +149,6 @@ devtools/server/tests/unit/babel_and_browserify_script_with_source_map.js
devtools/server/tests/unit/setBreakpoint*
devtools/server/tests/unit/sourcemapped.js
# Testing syntax error
devtools/client/webconsole/test/browser/test-syntaxerror-worklet.js
# devtools specific format test file
devtools/server/tests/unit/xpcshell_debugging_script.js

View file

@ -344,14 +344,13 @@ static bool WritePrincipalInfo(JSStructuredCloneWriter* aWriter,
JS_WriteBytes(aWriter, aBaseDomain.get(), aBaseDomain.Length());
}
/* static */
bool nsJSPrincipals::WritePrincipalInfo(JSStructuredCloneWriter* aWriter,
const PrincipalInfo& aInfo) {
static bool WritePrincipalInfo(JSStructuredCloneWriter* aWriter,
const PrincipalInfo& aInfo) {
if (aInfo.type() == PrincipalInfo::TNullPrincipalInfo) {
const NullPrincipalInfo& nullInfo = aInfo;
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_NULL_PRINCIPAL, 0) &&
::WritePrincipalInfo(aWriter, nullInfo.attrs(), nullInfo.spec(),
EmptyCString(), EmptyCString());
WritePrincipalInfo(aWriter, nullInfo.attrs(), nullInfo.spec(),
EmptyCString(), EmptyCString());
}
if (aInfo.type() == PrincipalInfo::TSystemPrincipalInfo) {
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_SYSTEM_PRINCIPAL, 0);
@ -374,8 +373,8 @@ bool nsJSPrincipals::WritePrincipalInfo(JSStructuredCloneWriter* aWriter,
MOZ_ASSERT(aInfo.type() == PrincipalInfo::TContentPrincipalInfo);
const ContentPrincipalInfo& cInfo = aInfo;
return JS_WriteUint32Pair(aWriter, SCTAG_DOM_CONTENT_PRINCIPAL, 0) &&
::WritePrincipalInfo(aWriter, cInfo.attrs(), cInfo.spec(),
cInfo.originNoSuffix(), cInfo.baseDomain());
WritePrincipalInfo(aWriter, cInfo.attrs(), cInfo.spec(),
cInfo.originNoSuffix(), cInfo.baseDomain());
}
bool nsJSPrincipals::write(JSContext* aCx, JSStructuredCloneWriter* aWriter) {

View file

@ -9,12 +9,6 @@
#include "jsapi.h"
#include "nsIPrincipal.h"
namespace mozilla {
namespace ipc {
class PrincipalInfo;
} // namespace ipc
} // namespace mozilla
class nsJSPrincipals : public nsIPrincipal, public JSPrincipals {
public:
/* SpiderMonkey security callbacks. */
@ -30,9 +24,6 @@ class nsJSPrincipals : public nsIPrincipal, public JSPrincipals {
uint32_t aTag,
JSPrincipals** aOutPrincipals);
/* For write() implementations of off-main-thread JSPrincipals. */
static bool WritePrincipalInfo(JSStructuredCloneWriter* aWriter,
const mozilla::ipc::PrincipalInfo& aInfo);
// This class is used on the main thread to specify which principal to use
// when reading principals data that was set on a DOM worker thread.
// DOM workers do not use principals from Gecko's point of view, and any

View file

@ -4,10 +4,7 @@ module.exports = {
// Extend from the shared list of defined globals for mochitests.
"extends": "../../../../.eslintrc.mochitests.js",
"overrides": [{
"files": [
"test-dynamic-import.js",
"test-error-worklet.js",
],
"files": ["test-dynamic-import.js"],
"parserOptions": {
"sourceType": "module",
},

View file

@ -59,8 +59,6 @@ support-files =
test-error-worker.html
test-error-worker.js
test-error-worker2.js
test-error-worklet.html
test-error-worklet.js
test-eval-error.html
test-eval-in-stackframe.html
test-eval-sources.html
@ -142,7 +140,6 @@ support-files =
test-subresource-security-error.html
test-subresource-security-error.js
test-subresource-security-error.js^headers^
test-syntaxerror-worklet.js
test-time-methods.html
test-trackingprotection-securityerrors.html
test-warning-groups.html
@ -504,4 +501,3 @@ skip-if = (os == "win" && bits == 32) && !debug # Bug 1560261
[browser_webconsole_websocket.js]
[browser_webconsole_worker_error.js]
[browser_webconsole_worker_evaluate.js]
[browser_webconsole_worklet_error.js]

View file

@ -1,27 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that syntax errors in worklet scripts show in the console and that
// throwing uncaught errors and primitive values in worklets shows a stack.
"use strict";
const TEST_URI =
"https://example.com/browser/devtools/client/webconsole/" +
"test/browser/test-error-worklet.html";
add_task(async function() {
await SpecialPowers.pushPrefEnv({
set: [["dom.audioworklet.enabled", true], ["dom.worklet.enabled", true]],
});
const hud = await openNewTabAndConsole(TEST_URI);
await waitFor(() =>
findMessage(hud, "SyntaxError: duplicate formal argument")
);
ok(true, "Received expected SyntaxError");
await checkMessageStack(hud, "addModule", [18, 21]);
await checkMessageStack(hud, "process", [7, 12]);
});

View file

@ -1,24 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Worklet error generator</title>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
</head>
<script>
"use strict";
const context = new AudioContext();
context.audioWorklet.addModule("test-syntaxerror-worklet.js").catch(
() => context.audioWorklet.addModule("test-error-worklet.js")
).then(() => {
const workletNode = new AudioWorkletNode(context, "error");
const oscillator = new OscillatorNode(context);
oscillator.connect(workletNode);
oscillator.start();
});
</script>
</html>

View file

@ -1,21 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function throw_process() {
throw "process"; // eslint-disable-line no-throw-literal
}
class ErrorProcessor extends AudioWorkletProcessor {
process() {
throw_process();
}
}
registerProcessor("error", ErrorProcessor);
function throw_error() {
throw new Error("addModule");
}
throw_error();

View file

@ -1,6 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
function f(a, a) {}

View file

@ -27,9 +27,9 @@ void SerializedStackHolder::WriteStack(JSContext* aCx,
JS_ClearPendingException(aCx);
}
void SerializedStackHolder::SerializeMainThreadOrWorkletStack(
JSContext* aCx, JS::HandleObject aStack) {
MOZ_ASSERT(!IsCurrentThreadRunningWorker());
void SerializedStackHolder::SerializeMainThreadStack(JSContext* aCx,
JS::HandleObject aStack) {
MOZ_ASSERT(NS_IsMainThread());
WriteStack(aCx, aStack);
}
@ -59,7 +59,7 @@ void SerializedStackHolder::SerializeCurrentStack(JSContext* aCx) {
if (stack) {
if (NS_IsMainThread()) {
SerializeMainThreadOrWorkletStack(aCx, stack);
SerializeMainThreadStack(aCx, stack);
} else {
WorkerPrivate* currentWorker = GetCurrentThreadWorkerPrivate();
SerializeWorkerStack(aCx, currentWorker, stack);

View file

@ -30,9 +30,8 @@ class SerializedStackHolder {
public:
SerializedStackHolder();
// Fill this holder with a main or worklet thread stack.
void SerializeMainThreadOrWorkletStack(JSContext* aCx,
JS::HandleObject aStack);
// Fill this holder with a main thread stack.
void SerializeMainThreadStack(JSContext* aCx, JS::HandleObject aStack);
// Fill this holder with a worker thread stack.
void SerializeWorkerStack(JSContext* aCx, WorkerPrivate* aWorkerPrivate,

View file

@ -65,7 +65,6 @@
#include "mozilla/dom/ErrorEvent.h"
#include "mozilla/dom/FetchUtil.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SerializedStackHolder.h"
#include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/SystemGroup.h"
#include "nsRefreshDriver.h"
@ -2617,32 +2616,6 @@ void mozilla::dom::ShutdownJSEnvironment() {
sDidShutdown = true;
}
AsyncErrorReporter::AsyncErrorReporter(xpc::ErrorReport* aReport)
: Runnable("dom::AsyncErrorReporter"), mReport(aReport) {}
void AsyncErrorReporter::SerializeStack(JSContext* aCx,
JS::Handle<JSObject*> aStack) {
mStackHolder = MakeUnique<SerializedStackHolder>();
mStackHolder->SerializeMainThreadOrWorkletStack(aCx, aStack);
}
NS_IMETHODIMP AsyncErrorReporter::Run() {
AutoJSAPI jsapi;
DebugOnly<bool> ok = jsapi.Init(xpc::UnprivilegedJunkScope());
MOZ_ASSERT(ok, "Problem with junk scope?");
JSContext* cx = jsapi.cx();
JS::Rooted<JSObject*> stack(cx);
JS::Rooted<JSObject*> stackGlobal(cx);
if (mStackHolder) {
stack = mStackHolder->ReadStack(cx);
if (stack) {
stackGlobal = JS::CurrentGlobalOrNull(cx);
}
}
mReport->LogToConsoleWithStack(stack, stackGlobal);
return NS_OK;
}
// A fast-array class for JS. This class supports both nsIJSScriptArray and
// nsIArray. If it is JS itself providing and consuming this class, all work
// can be done via nsIJSScriptArray, and avoid the conversion of elements

View file

@ -151,27 +151,22 @@ class nsJSContext : public nsIScriptContext {
namespace mozilla {
namespace dom {
class SerializedStackHolder;
void StartupJSEnvironment();
void ShutdownJSEnvironment();
// Runnable that's used to do async error reporting
class AsyncErrorReporter final : public mozilla::Runnable {
public:
explicit AsyncErrorReporter(xpc::ErrorReport* aReport);
// SerializeStack is suitable for main or worklet thread use.
// Stacks from worker threads are not supported.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1578968
void SerializeStack(JSContext* aCx, JS::Handle<JSObject*> aStack);
explicit AsyncErrorReporter(xpc::ErrorReport* aReport)
: Runnable("dom::AsyncErrorReporter"), mReport(aReport) {}
NS_IMETHOD Run() override {
mReport->LogToConsole();
return NS_OK;
}
protected:
NS_IMETHOD Run() override;
RefPtr<xpc::ErrorReport> mReport;
// This may be used to marshal a stack from an arbitrary thread/runtime into
// the main thread/runtime where the console service runs.
UniquePtr<SerializedStackHolder> mStackHolder;
};
} // namespace dom

View file

@ -570,7 +570,7 @@ class ConsoleCallDataWorkletRunnable final : public ConsoleWorkletRunnable {
AutoSafeJSContext cx;
JSObject* sandbox =
mConsole->GetOrCreateSandbox(cx, mWorkletImpl->Principal());
mConsole->GetOrCreateSandbox(cx, mWorkletImpl->LoadInfo().Principal());
JS::Rooted<JSObject*> global(cx, sandbox);
if (NS_WARN_IF(!global)) {
return;
@ -818,7 +818,7 @@ class ConsoleProfileWorkletRunnable final : public ConsoleWorkletRunnable {
AutoSafeJSContext cx;
JSObject* sandbox =
mConsole->GetOrCreateSandbox(cx, mWorkletImpl->Principal());
mConsole->GetOrCreateSandbox(cx, mWorkletImpl->LoadInfo().Principal());
JS::Rooted<JSObject*> global(cx, sandbox);
if (NS_WARN_IF(!global)) {
return;
@ -1445,7 +1445,7 @@ void Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
} else if (WorkletThread::IsOnWorkletThread()) {
nsCOMPtr<WorkletGlobalScope> global = do_QueryInterface(mGlobal);
MOZ_ASSERT(global);
oa = global->Impl()->OriginAttributesRef();
oa = global->Impl()->LoadInfo().OriginAttributesRef();
} else {
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate);

View file

@ -10,7 +10,6 @@
#include "WorkletThread.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/dom/RegisterWorkletBindings.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/WorkletBinding.h"
@ -20,8 +19,11 @@ namespace mozilla {
// ---------------------------------------------------------------------------
// WorkletLoadInfo
WorkletLoadInfo::WorkletLoadInfo(nsPIDOMWindowInner* aWindow)
: mInnerWindowID(aWindow->WindowID()) {
WorkletLoadInfo::WorkletLoadInfo(nsPIDOMWindowInner* aWindow,
nsIPrincipal* aPrincipal)
: mInnerWindowID(aWindow->WindowID()),
mOriginAttributes(BasePrincipal::Cast(aPrincipal)->OriginAttributesRef()),
mPrincipal(aPrincipal) {
MOZ_ASSERT(NS_IsMainThread());
nsPIDOMWindowOuter* outerWindow = aWindow->GetOuterWindow();
if (outerWindow) {
@ -31,21 +33,17 @@ WorkletLoadInfo::WorkletLoadInfo(nsPIDOMWindowInner* aWindow)
}
}
WorkletLoadInfo::~WorkletLoadInfo() {
MOZ_ASSERT(!mPrincipal || NS_IsMainThread());
}
// ---------------------------------------------------------------------------
// WorkletImpl
WorkletImpl::WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
: mPrincipal(NullPrincipal::CreateWithInheritedAttributes(aPrincipal)),
mWorkletLoadInfo(aWindow),
mTerminated(false) {
Unused << NS_WARN_IF(
NS_FAILED(ipc::PrincipalToPrincipalInfo(mPrincipal, &mPrincipalInfo)));
}
: mWorkletLoadInfo(aWindow, aPrincipal), mTerminated(false) {}
WorkletImpl::~WorkletImpl() {
MOZ_ASSERT(!mGlobalScope);
MOZ_ASSERT(!mPrincipal || NS_IsMainThread());
}
WorkletImpl::~WorkletImpl() { MOZ_ASSERT(!mGlobalScope); }
JSObject* WorkletImpl::WrapWorklet(JSContext* aCx, dom::Worklet* aWorklet,
JS::Handle<JSObject*> aGivenProto) {
@ -98,7 +96,7 @@ void WorkletImpl::NotifyWorkletFinished() {
mWorkletThread->Terminate();
mWorkletThread = nullptr;
}
mPrincipal = nullptr;
mWorkletLoadInfo.mPrincipal = nullptr;
}
nsresult WorkletImpl::SendControlMessage(

View file

@ -9,7 +9,6 @@
#include "MainThreadUtils.h"
#include "mozilla/OriginAttributes.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h"
class nsPIDOMWindowInner;
class nsIPrincipal;
@ -27,15 +26,31 @@ class WorkletThread;
class WorkletLoadInfo {
public:
explicit WorkletLoadInfo(nsPIDOMWindowInner* aWindow);
WorkletLoadInfo(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal);
~WorkletLoadInfo();
uint64_t OuterWindowID() const { return mOuterWindowID; }
uint64_t InnerWindowID() const { return mInnerWindowID; }
const OriginAttributes& OriginAttributesRef() const {
return mOriginAttributes;
}
nsIPrincipal* Principal() const {
MOZ_ASSERT(NS_IsMainThread());
return mPrincipal;
}
private:
// Modified only in constructor.
uint64_t mOuterWindowID;
const uint64_t mInnerWindowID;
const OriginAttributes mOriginAttributes;
// Accessed on only worklet parent thread.
nsCOMPtr<nsIPrincipal> mPrincipal;
friend class WorkletImpl;
friend class WorkletThread;
};
/**
@ -56,11 +71,6 @@ class WorkletImpl {
virtual nsresult SendControlMessage(already_AddRefed<nsIRunnable> aRunnable);
nsIPrincipal* Principal() const {
MOZ_ASSERT(NS_IsMainThread());
return mPrincipal;
}
void NotifyWorkletFinished();
// Execution thread only.
@ -69,10 +79,6 @@ class WorkletImpl {
// Any thread.
const WorkletLoadInfo& LoadInfo() const { return mWorkletLoadInfo; }
const OriginAttributes& OriginAttributesRef() const {
return mPrincipalInfo.get_NullPrincipalInfo().attrs();
}
const ipc::PrincipalInfo& PrincipalInfo() const { return mPrincipalInfo; }
protected:
WorkletImpl(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal);
@ -80,12 +86,9 @@ class WorkletImpl {
virtual already_AddRefed<dom::WorkletGlobalScope> ConstructGlobalScope() = 0;
// Modified only in constructor.
ipc::PrincipalInfo mPrincipalInfo;
// Accessed on only worklet parent thread.
nsCOMPtr<nsIPrincipal> mPrincipal;
const WorkletLoadInfo mWorkletLoadInfo;
// The only WorkletLoadInfo member modified is mPrincipal which is accessed
// on only the parent thread.
WorkletLoadInfo mWorkletLoadInfo;
// Parent thread only.
RefPtr<dom::WorkletThread> mWorkletThread;

View file

@ -6,7 +6,7 @@
#include "WorkletPrincipals.h"
#include "nsJSPrincipals.h"
#include "mozilla/Assertions.h"
namespace mozilla {
namespace dom {
@ -20,11 +20,8 @@ WorkletPrincipals::~WorkletPrincipals() = default;
bool WorkletPrincipals::write(JSContext* aCx,
JSStructuredCloneWriter* aWriter) {
// This is a serialization of the NullPrincipal corresponding to the worklet
// environment settings object for the WorkletGlobalScope.
// https://drafts.css-houdini.org/worklets/#set-up-a-worklet-environment-settings-object
return nsJSPrincipals::WritePrincipalInfo(aWriter,
mWorkletImpl->PrincipalInfo());
MOZ_CRASH("WorkletPrincipals::write not implemented");
return false;
}
void WorkletPrincipals::Destroy(JSPrincipals* aPrincipals) {

View file

@ -186,22 +186,8 @@ void WorkletJSContext::ReportError(JSErrorReport* aReport,
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
xpcReport->Init(aReport, aToStringResult.c_str(), IsSystemCaller(),
GetCurrentWorkletWindowID());
RefPtr<AsyncErrorReporter> reporter = new AsyncErrorReporter(xpcReport);
JSContext* cx = Context();
JS::Rooted<JS::Value> exn(cx);
if (JS_GetPendingException(cx, &exn)) {
JS::Rooted<JSObject*> exnStack(cx, JS::GetPendingExceptionStack(cx));
JS_ClearPendingException(cx);
JS::Rooted<JSObject*> stack(cx);
JS::Rooted<JSObject*> stackGlobal(cx);
xpc::FindExceptionStackForConsoleReport(nullptr, exn, exnStack, &stack,
&stackGlobal);
if (stack) {
reporter->SerializeStack(cx, stack);
}
}
NS_DispatchToMainThread(reporter);
}