Skip to content

Commit

Permalink
Bug 1558128 report errors from worklet scripts to console r=baku
Browse files Browse the repository at this point in the history
There is no ErrorEvent dispatched to WorkletGlobalScope.
See also whatwg/html#2611

Differential Revision: https://phabricator.services.mozilla.com/D44600

--HG--
extra : moz-landing-system : lando
  • Loading branch information
karlt committed Sep 4, 2019
1 parent 9c8bc82 commit 289744e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions dom/worklet/WorkletThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,33 @@ class WorkletJSContext final : public CycleCollectedJSContext {
}

void ReportError(JSErrorReport* aReport,
JS::ConstUTF8CharsZ aToStringResult) override {
// TODO: bug 1558128;
JS::ConstUTF8CharsZ aToStringResult) override;

uint64_t GetCurrentWorkletWindowID() {
JSObject* global = JS::CurrentGlobalOrNull(Context());
if (NS_WARN_IF(!global)) {
return 0;
}
nsIGlobalObject* nativeGlobal = xpc::NativeGlobal(global);
nsCOMPtr<WorkletGlobalScope> workletGlobal =
do_QueryInterface(nativeGlobal);
if (NS_WARN_IF(!workletGlobal)) {
return 0;
}
return workletGlobal->Impl()->LoadInfo().InnerWindowID();
}
};

void WorkletJSContext::ReportError(JSErrorReport* aReport,
JS::ConstUTF8CharsZ aToStringResult) {
RefPtr<xpc::ErrorReport> xpcReport = new xpc::ErrorReport();
xpcReport->Init(aReport, aToStringResult.c_str(), IsSystemCaller(),
GetCurrentWorkletWindowID());

RefPtr<AsyncErrorReporter> reporter = new AsyncErrorReporter(xpcReport);
NS_DispatchToMainThread(reporter);
}

// This is the first runnable to be dispatched. It calls the RunEventLoop() so
// basically everything happens into this runnable. The reason behind this
// approach is that, when the Worklet is terminated, it must not have any JS in
Expand Down

0 comments on commit 289744e

Please sign in to comment.