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

UltraBlame original commit: 1069ae045160d78eb4d38aeaecfe8e66f6faeed7
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 830e76b commit 5e84752
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 {

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);
}




Expand Down

0 comments on commit 5e84752

Please sign in to comment.