Closed Bug 1411521 Opened 6 years ago Closed 6 years ago

[PWA] javascript:void(0) is opened as external page on page added to home screen


(Firefox for Android Graveyard :: Web Apps (PWAs), defect, P1)

58 Branch


(firefox59 verified)

Firefox 59
Tracking Status
firefox59 --- verified


(Reporter: krzysdz, Assigned: droeh)




(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Build ID: 20171024220325

Steps to reproduce:

I've added to home screen and I've clicked "Menu" button (it's visible only on small screens). It is an "a" element with href="javascript:void(0)"

Actual results:

A tab with url "javascript:void(0)" has opened (like on attached screenshot)

Expected results:

On Chrome and Firefox Nightly in normal browser menu just opens, without a new empty tab.
Please help prioritize this
Flags: needinfo?(wehuang)
Flags: needinfo?(jcheng)
Priority: -- → P1
Adding something like:

if (urlStr.startsWith("javascript:")){
    return false;

in mobile/android/base/java/org/mozilla/gecko/webapps/ in onLoadUri (before `if ("http"...` - about line 324) helps, but I'm not sure if it is a proper way to solve this problem (I was wondering if return true would also work, but it breaks things like `<a href="javascript:alert('TEST')">test</a>`, while returning false makes everything work good - no new tab and alert works).
It would be great if you could check it.
Hi snorp
Do you think we should handle this in GeckoView?
Flags: needinfo?(snorp)
Summary: javascript:void(0) is opened as external page on page added to home screen → [PWA] javascript:void(0) is opened as external page on page added to home screen
Dylan, looks like this is another edge case to handle.
Flags: needinfo?(snorp) → needinfo?(droeh)
Yeah, javascript: uris will currently get bounced to custom tabs because they fail the scope check. This patch just adds a special case for them in onLoadUri().
Assignee: nobody → droeh
Ever confirmed: true
Flags: needinfo?(droeh)
Attachment #8931056 - Flags: review?(snorp)
Attachment #8931056 - Flags: review?(snorp) → review+
Pushed by
Handle javascript: URIs properly in PWAs. r=snorp
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 59
Flags: needinfo?(wehuang)
Flags: needinfo?(jcheng)
Verified as fixed on Nightly 59 (2018-01-08).
Device: Prestigio Grace X5 (Android 4.4.2)
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.