Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will-navigate not triggered for some website. #14751

Closed
erguotou520 opened this issue Sep 21, 2018 · 16 comments
Closed

will-navigate not triggered for some website. #14751

erguotou520 opened this issue Sep 21, 2018 · 16 comments

Comments

@erguotou520
Copy link

  • Output of node_modules/.bin/electron --version: 3.0.0-beta8
  • Operating System (Platform and Version): win/mac
  • Output of node_modules/.bin/electron --version on last known working Electron version (if applicable): 3.0.0

Expected Behavior
will-navigate event can be triggered successfully.

Actual behavior
will-navigate is not triggered.

To Reproduce
We have QQ oath login function in our electron app. The oauth url looks like https://graph.qq.com/oauth2.0/authorize?client_id=xxx&redirect_uri=xxx&response_type=code&scope=get_user_info&state=xxx.

We can success catch the will-navigate event in electron@2.0.8 as well as 2.0.10, but failed when update electron to 3.x(tried 3.0.0-beta8 and 3.0.0).

Another wechat oauth function works well for both electron 2.x and 3.x and it's url looks like https://open.weixin.qq.com/connect/qrconnect?appid=xxx&redirect_uri=xxx&response_type=code&scope=snsapi_login&state=xxx#wechat_redirect

Additional Information
Some major code:

win.webContents.on('will-navigate', (e, redirectUrl) => {
  if (redirectUrl.startsWith(this.callbackUrl)) {
    e.preventDefault()
    // do something
  }
})
@akozich
Copy link

akozich commented Sep 30, 2018

Faced the same issue. Reproducible on 3.0.0 and 3.0.2. I found that 'will-navigate' is triggered whenever any link is clicked but is not triggered when location is changed by form submission.

@akozich
Copy link

akozich commented Sep 30, 2018

2.0.10 works well

@NicoAiko
Copy link

I also face this issue!
Still reproducible on 3.0.3 and 3.0.4!

Please fix this asap!

@Thomas101
Copy link
Contributor

In my experience it seems to fail on the vast majority of navigations. You can bind up to the session.webRequest and listen for onBeforeRequest to work around this.

If you're following the security advice on navigation and haven't noticed this, there's potential for security holes downstream :-/

@guillaumearm
Copy link

same on Electron 3.0.5

@andywampir
Copy link
Contributor

same on Electron 3.0.8

@9aram
Copy link

9aram commented Mar 19, 2019

use did-navigate it works to me! :)

@sachetsharma1
Copy link

Is the a planned fix version for this?

@goodhyun
Copy link

Even 5.0.1 has this issue: Tumblr and Wordpress.com logins were affected, FB/Twitter seem okay though.

@MarshallOfSound
Copy link
Member

will-navigate does not get emitted for redirects inside the navigation chain.

You need to subscribe to will-redirect to get that information

🔗 https://electronjs.org/docs/api/web-contents#event-will-redirect

@sofianguy
Copy link
Contributor

Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases.

If you're still experiencing this issue in Electron v4.2.x or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

Thanks in advance! Your help is appreciated.

@sofianguy sofianguy added the blocked/need-info ❌ Cannot proceed without more information label Aug 9, 2019
@sofianguy
Copy link
Contributor

Thank you for your issue!

We haven't gotten a response to our questions in our comment above. With only the information that is currently in the issue, we don't have enough information to take action. I'm going to close this but don't hesitate to reach out if you have or find the answers we need, we'll be happy to reopen the issue.

@zengpeng123
Copy link

This problem still exists in version 6.0.2.

@sofianguy sofianguy added 6-0-x and removed blocked/need-info ❌ Cannot proceed without more information labels Sep 18, 2019
@sofianguy sofianguy reopened this Sep 18, 2019
@goodhyun
Copy link

As @MarshallOfSound advised, will-redirect can safely replace will-navigate in a certain situation such as LinkedIn login windows.

@thisconnect
Copy link

In my case will-navigate did not triggering because my create-react-app sample uses target="_blank" see also https://github.com/facebook/create-react-app/blob/1a66971f9e2f255d6278ade61e70517faf5839db/packages/cra-template/template/src/App.js#L16

this can be caught with https://electronjs.org/docs/tutorial/security#13-disable-or-limit-creation-of-new-windows

@electron-triage
Copy link

The Electron version reported on this issue is no longer supported. See our supported versions documentation.

If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.

Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
3.0.x / 3.1.x
Unsorted Issues
Development

No branches or pull requests