Closed Bug 1570588 Opened 5 years ago Closed 5 years ago

JavaScript error - Notification is not defined

Categories

(Core :: DOM: Push Subscriptions, defect)

70 Branch
defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox70 --- affected

People

(Reporter: krzysztof.glebowicz, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0

Steps to reproduce:

  1. This bug looks like Win7 specific
  2. Run the following code:

try
{
var pushPermission=Notification.permission;

alert(pushPermission);
}
catch (err)
{
alert(err.message);
}

Actual results:

Win10: blocked

Win7: Notification is not defined

Expected results:

I'd expect (for instance): alert(blocked) on Win7.

This bug breaks this site: https://my.xe.gr/login?from=myxe_new_landing

Hi Krzysztof,

Can you be more detailed? I imagine that the code is missing the header and footer, can you give me a complete file? (You may attach it). Also, once I have this file, all I have to do it is open it with Firefox, right?

On the other hand, I was able to access the site both with Windows 10 and Windows 7 without problems. On what step does it fail?

Thanks in advance, Flor.

Flags: needinfo?(krzysztof.glebowicz)
Attached file testcase
Flags: needinfo?(krzysztof.glebowicz)

Hi Florencia,

testcase is attached. It may be nessesary to set dom.webnotifications.enabled = false.

On the other hand, I was able to access the site both with Windows 10 and Windows 7 without problems. On what step does it fail?

On win7 there is an error in the Console: ReferenceError: Notification is not defined. When you enter some characters in both fields and press the button beneath, nothing is happening.

Hi Krzysztof,

Thank you very much for the details. I was able to reproduce the bug on Windows 7 64 bits using release 68.0.1 (64-bit). I've chosen a component. If you consider that there's another component that's more proper for this case you may change it.

Best regards, Flor.

Status: UNCONFIRMED → NEW
Component: Untriaged → JavaScript: Standard Library
Ever confirmed: true
Product: Firefox → Core
Component: JavaScript: Standard Library → DOM: Push Notifications

Hi Krzysztof, thanks for the report! Setting dom.webnotifications.enabled to false hides the Notification constructor from the page, so this is expected behavior. Unfortunately, that means sites that don't use a feature check, like if ("Notification" in window) { let p = Notification.permission; /* ... */ }, will break. 😕

Can you repro without that pref set?

(And, if you'd like to stop sites from asking permission to show notifications, you can open about:preferences#privacy, scroll down to "Permissions", click "Settings...", and check "Block new requests asking to allow notifications").

Flags: needinfo?(krzysztof.glebowicz)

Thanks for explanations, Lina. It works as expected.

One more thing. This page https://my.xe.gr/login?from=myxe_new_landing works fine with dom.webnotifications.enabled = false in the private mode. This is quite strange for me, but perhaps in this mode page doesn't ask for this permission at all.

This bug can be resolved as INVALID.

Flags: needinfo?(krzysztof.glebowicz)

(marking invalid per comment 6)

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: