Closed Bug 1412856 Opened 7 years ago Closed 4 years ago

replace direct usage NS_ERROR_DOM_TYPE_ERR in service workers with ErrorResult values with messages

Categories

(Core :: DOM: Service Workers, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: bkelly, Assigned: bzbarsky)

References

(Blocks 2 open bugs)

Details

Attachments

(6 files)

We have some places in service worker code where we throw or reject promises with NS_ERROR_DOM_TYPE_ERR.  This is ok per the spec, but these call sites don't provide a meaningful message to developers.  We should improve this code by using ErrorResult with a message.

To do this, however, we also need to make some improvements to ErrorResult to allow passing these more complex rejection values across IPC.  Some work in progress on that is in bug 1357463.

I had hoped to fix/avoid some of this in bug 1293277, but it was becoming a large project and we need to finish that work soon to unblock other work.
Priority: -- → P3
> This is ok per the spec

I really doubt it.  It produces a DOMException with name == TypeError, not an actual TypeError.  Unfortunately, testharness just tests .name, not what the object really is.
(In reply to Boris Zbarsky [:bz] (no decent commit message means r-) from comment #1)
> I really doubt it.  It produces a DOMException with name == TypeError, not
> an actual TypeError.  Unfortunately, testharness just tests .name, not what
> the object really is.

I was not aware of that.  FWIW, I don't think I made the problem any worse than it was before and have now added the primitives to fix it in the future.
Blocks: 1581172

CopyableErrorResult might help here...

Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED

I think the current code made us filter out all the carefully crafted TypeError
messages we might have reported...

Some of these error messages are not very informative; better ones would be appreciated.

For some of these I had to take a guess due to lack of familiarity with this
code, so careful review of the actual strings would be much appreciated.

There's still a bunch of code in dom/serviceworkers that constructs a
CopyableErrorResult from just an nsresult, but I don't understand that code well
enough to write good error messages.

Depends on: 1612135

Just to make sure it doesn't get lost: part 6 here still needs review.

Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0a3bf632a719
part 1.  Change ClientOpPromise to use a CopyableErrorResult for its rejection type.  r=dom-workers-and-storage-reviewers,sg?
https://hg.mozilla.org/integration/autoland/rev/aafd7c5a9d47
part 2.  Stop using NS_ERROR_DOM_TYPE_ERR in Client::Navigate.  r=dom-workers-and-storage-reviewers,perry?
https://hg.mozilla.org/integration/autoland/rev/1cac745bf19e
part 3.  Test for the right exception code for TypeErrors.  r=dom-workers-and-storage-reviewers,perry?
https://hg.mozilla.org/integration/autoland/rev/8c749ce01fb9
part 4.  Make SourcePromise have CopyableErrorResult as its rejection type.  r=dom-workers-and-storage-reviewers,sg?
https://hg.mozilla.org/integration/autoland/rev/c9d48dee0b74
part 5.  Remove use of NS_ERROR_DOM_TYPE_ERR from Clients.openWindow.  r=dom-workers-and-storage-reviewers,perry?
https://hg.mozilla.org/integration/autoland/rev/659060314d6d
part 6.  Add more useful error messages for serviceworker exceptions.  r=dom-workers-and-storage-reviewers,perry?
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/21557 for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Blocks: dom-error
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: