Closed Bug 1411521 Opened 3 years ago Closed 2 years ago

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

Categories

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

58 Branch
defect

Tracking

()

RESOLVED FIXED
Firefox 59
Tracking Status
firefox59 --- verified

People

(Reporter: krzysdz, Assigned: droeh)

References

(Blocks 1 open bug)

Details

Attachments

(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 https://anulowano.pl/ 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/WebAppActivity.java 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
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(droeh)
Attachment #8931056 - Flags: review?(snorp)
Attachment #8931056 - Flags: review?(snorp) → review+
Pushed by droeh@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/f4851b138288
Handle javascript: URIs properly in PWAs. r=snorp
https://hg.mozilla.org/mozilla-central/rev/f4851b138288
Status: NEW → RESOLVED
Closed: 2 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)
You need to log in before you can comment on or make changes to this bug.