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

RESOLVED FIXED in Firefox 45

Status

()

Core
DOM: Push Notifications
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: callahad, Assigned: kitcambridge)

Tracking

({DevAdvocacy})

unspecified
mozilla45
DevAdvocacy
Points:
---

Firefox Tracking Flags

(firefox45 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

2 years ago
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
(Reporter)

Comment 1

2 years ago
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
Created attachment 8663950 [details] [diff] [review]
0001-Bug-1206302-Use-DOMException-for-push-methods.patch

WIP patch.
Attachment #8663950 - Attachment is obsolete: true
Created attachment 8682280 [details]
MozReview Request: Bug 1206302 - Use `DOMException` for Push errors. r=mt

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

Comment 8

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/73aef6e86bff
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox45: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Blocks: 1243781
You need to log in before you can comment on or make changes to this bug.