Closed Bug 1113582 Opened 10 years ago Closed 9 years ago

Fix ServiceWorker error handling during installation.

Categories

(Core :: DOM: Workers, defect)

33 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38

People

(Reporter: nsm, Assigned: nsm)

References

Details

Attachments

(1 file)

ServiceWorker parse/network errors should reject the promise returned by register().
Folded:
Enable network error detection test. Fix scopes for network test and parse...

... test to deal with https://github.com/slightlyoff/ServiceWorker/issues/547
Attachment #8539211 - Flags: review?(amarchesini)
Assignee: nobody → nsm.nikhil
Status: NEW → ASSIGNED
Comment on attachment 8539211 [details] [diff] [review]
ServiceWorker parse errors are now properly handled during the Update phase

Review of attachment 8539211 [details] [diff] [review]:
-----------------------------------------------------------------

Can you ask someone to take a look the JS part?

::: dom/workers/ServiceWorkerManager.cpp
@@ +308,5 @@
> +    mPromise->MaybeReject(cx, error);
> +  }
> +};
> +
> +class ContinueUpdateRunnable : public nsRunnable

MOZ_FINAL

@@ +314,5 @@
> +  nsMainThreadPtrHandle<nsISupports> mJob;
> +public:
> +  explicit ContinueUpdateRunnable(const nsMainThreadPtrHandle<nsISupports> aJob)
> +    : mJob(aJob)
> +  { }

ASSERT worker thread

@@ +327,5 @@
> +  CheckWorkerEvaluationAndContinueUpdateWorkerRunnable(WorkerPrivate* aWorkerPrivate,
> +                                                       const nsMainThreadPtrHandle<nsISupports> aJob)
> +    : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount)
> +    , mJob(aJob)
> +  { }

In which thread can this obj be created? Can we have an assertion?

@@ +479,5 @@
> +        new nsMainThreadPtrHolder<nsISupports>(upcasted));
> +
> +    nsRefPtr<CheckWorkerEvaluationAndContinueUpdateWorkerRunnable> r =
> +      new CheckWorkerEvaluationAndContinueUpdateWorkerRunnable(serviceWorker->GetWorkerPrivate(), handle);
> +    AutoSafeJSContext cx;

AutoJSAPI here.

@@ +481,5 @@
> +    nsRefPtr<CheckWorkerEvaluationAndContinueUpdateWorkerRunnable> r =
> +      new CheckWorkerEvaluationAndContinueUpdateWorkerRunnable(serviceWorker->GetWorkerPrivate(), handle);
> +    AutoSafeJSContext cx;
> +    bool ok = r->Dispatch(cx);
> +    if (!ok) {

NS_WARN_IF(!ok)

@@ +546,5 @@
> +
> +    nsRefPtr<InstallEventRunnable> r =
> +      new InstallEventRunnable(serviceWorker->GetWorkerPrivate(), handle, mRegistration->mScope);
> +
> +    AutoSafeJSContext cx;

AutoJSAPI
Attachment #8539211 - Flags: review?(amarchesini) → review+
Comment on attachment 8539211 [details] [diff] [review]
ServiceWorker parse errors are now properly handled during the Update phase

Boris, in UpdateFailed(const ErrorEventInit& aErrorDesc), I'm converting the dictionary to a JS error and rejecting a Promise. Could you verify I'm not making any JSAPI boo-boo.
Attachment #8539211 - Flags: review?(bzbarsky)
Comment on attachment 8539211 [details] [diff] [review]
ServiceWorker parse errors are now properly handled during the Update phase

If ToJSValue returns false you need to either report the exception on the cx or clear it.  Probably the latter in your case.

Same thing if CreateError returns false.

Apart from that, UpdateFailed looks fine.
Attachment #8539211 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/mozilla-central/rev/3bf6b6a31b6a
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: