Closed Bug 1206302 Opened 9 years ago Closed 9 years ago

pushManager.subscribe rejects with string "PermissionDeniedError" instead of DOMException

Categories

(Core :: DOM: Push Subscriptions, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: callahad, Assigned: lina)

References

Details

(Keywords: DevAdvocacy)

Attachments

(1 file, 1 obsolete file)

When pushManager.subscribe() fails, the spec states that it should:

> reject promise with a DOMException whose name is "PermissionDeniedError"

We reject with the literal string "PermissionDeniedError" instead.

Spec: https://w3c.github.io/push-api/#idl-def-PushManager

Code: https://dxr.mozilla.org/mozilla-central/rev/9ed17db42e3e46f1c712e4dffd62d54e915e0fac/dom/push/Push.js?offset=0#152-154
Steps to Reproduce:

1. Visit a page with a serviceworker, like https://mdn.github.io/sw-test/

2. In the console, run:

    var x;
    navigator.serviceWorker.ready
      .then(reg => reg.pushManager.subscribe())
      .catch(e => {
        x = e;

        let example = new DOMException("PermissionDeniedError");

        console.log("Subscription failed.");
        console.log("Type of error is:", typeof e, "(", e ,")");
        console.log("Error", e instanceof DOMException ? "is" : "IS NOT", "an instanceof DOMException");
        console.log("The error has been assigned to global variable `x` for inspection.");
      });

3. In the permissions doorhanger, choose to block notifications.
Assignee: nobody → kcambridge
WIP patch.
Attachment #8663950 - Attachment is obsolete: true
Bug 1206302 - Use `DOMException` for Push errors. r?mt
Attachment #8682280 - Flags: review?(martin.thomson)
Comment on attachment 8682280 [details]
MozReview Request: Bug 1206302 - Use `DOMException` for Push errors. r=mt

https://reviewboard.mozilla.org/r/24039/#review21631

This looks fine.  I'm a little surprised that you don't have any tests for this though.
Attachment #8682280 - Flags: review?(martin.thomson) → review+
Comment on attachment 8682280 [details]
MozReview Request: Bug 1206302 - Use `DOMException` for Push errors. r=mt

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/24039/diff/1-2/
Attachment #8682280 - Attachment description: MozReview Request: Bug 1206302 - Use `DOMException` for Push errors. r?mt → MozReview Request: Bug 1206302 - Use `DOMException` for Push errors. r=mt
https://hg.mozilla.org/mozilla-central/rev/73aef6e86bff
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Blocks: 1243781
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: