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

fix: promise resolved to early when browser initiated in-page navigation #39260

Conversation

TomaszMa
Copy link
Contributor

Description of Change

After this fix #36129 promise returned by loadURL function can be resolved before page finish loading. While page is loading it can trigger browser intendent in page navigation (e.g.: window.history.replaceState ). This PR fixes this problem.

Checklist

Release Notes

Notes: Fix problem with promise resolved to early when browser intendent in-page navigation

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 27, 2023
@TomaszMa
Copy link
Contributor Author

@nornagon can you review this fix/change ? Thanks.

Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the lint warnings?

/home/builduser/project/src/electron/lib/browser/api/web-contents.ts
  450:9   error  Identifier 'browser_intendent_in_page_navigation' is not in camel case  camelcase
  465:9   error  Identifier 'browser_intendent_in_page_navigation' is not in camel case  camelcase
  481:12  error  Identifier 'browser_intendent_in_page_navigation' is not in camel case  camelcase

/home/builduser/project/src/electron/spec/api-web-contents-spec.ts
  380:51  error  Missing space before function parentheses      space-before-function-paren
  381:1   error  Expected indentation of 8 spaces but found 10  indent

The code looks good to me.

@TomaszMa
Copy link
Contributor Author

Can you fix the lint warnings?

/home/builduser/project/src/electron/lib/browser/api/web-contents.ts
  450:9   error  Identifier 'browser_intendent_in_page_navigation' is not in camel case  camelcase
  465:9   error  Identifier 'browser_intendent_in_page_navigation' is not in camel case  camelcase
  481:12  error  Identifier 'browser_intendent_in_page_navigation' is not in camel case  camelcase

/home/builduser/project/src/electron/spec/api-web-contents-spec.ts
  380:51  error  Missing space before function parentheses      space-before-function-paren
  381:1   error  Expected indentation of 8 spaces but found 10  indent

The code looks good to me.

Warnings fixed.

@zcbenz zcbenz added semver/patch backwards-compatible bug fixes target/24-x-y PR should also be added to the "24-x-y" branch. target/25-x-y PR should also be added to the "25-x-y" branch. target/26-x-y PR should also be added to the "26-x-y" branch. labels Aug 1, 2023
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Aug 1, 2023
@codebytere
Copy link
Member

@TomaszMa can you clarify what is meant by "browser intendent navigation"? I'm not sure I understand what that term refers to and haven't seen it before.

@TomaszMa
Copy link
Contributor Author

TomaszMa commented Aug 8, 2023

@TomaszMa can you clarify what is meant by "browser intendent navigation"? I'm not sure I understand what that term refers to and haven't seen it before.

browser intendent navigation - navigation triggered by browser, e.g.: loading resources like images . Navigation indirectly caused by user. Some of the browser intendent navigation can trigger 'did-navigate-in-page' event, e.g.: window.history.replaceState . google.com page calls window.history.replaceState which triggers 'did-navigate-in-page'.

user intendent navigation - navigation triggered by user, e.g.: BrowserWindow.loadURL, BrowserWindow.loadFile, or user clicking on hyper link. Every navigation directly caused by user.

Problem is that when we call BrowserWindow.loadFile (user intendent navigation) we get Promise which is resolved before page will load because there can be browser intendent in page navigation. This PR fixes this problem.

Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomaszMa ok thanks. I was asking mostly because "intendent" isn't really a term that's used. We should something that more clearly conveys what's going on - browserInitiated and userInitiated are clearer. Let's instead say browserInitiatedInPageNavigation and finishListenerWhenUserIntendentNavigation.

@TomaszMa TomaszMa changed the title fix: promise resolved to early when browser intendent in-page navigation fix: promise resolved to early when browser initiated in-page navigation Aug 8, 2023
@TomaszMa
Copy link
Contributor Author

TomaszMa commented Aug 8, 2023

@codebytere changed :)

Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks :D

@codebytere codebytere merged commit a0effaf into electron:main Aug 9, 2023
18 checks passed
@release-clerk
Copy link

release-clerk bot commented Aug 9, 2023

Release Notes Persisted

Fix problem with promise resolved to early when browser intendent in-page navigation

@welcome
Copy link

welcome bot commented Aug 9, 2023

Congrats on merging your first pull request! 🎉🎉🎉

@trop
Copy link
Contributor

trop bot commented Aug 9, 2023

I have automatically backported this PR to "24-x-y", please check out #39432

@trop trop bot added in-flight/24-x-y and removed target/24-x-y PR should also be added to the "24-x-y" branch. labels Aug 9, 2023
@trop
Copy link
Contributor

trop bot commented Aug 9, 2023

I have automatically backported this PR to "26-x-y", please check out #39433

@trop
Copy link
Contributor

trop bot commented Aug 9, 2023

I have automatically backported this PR to "25-x-y", please check out #39434

@trop trop bot added in-flight/26-x-y in-flight/25-x-y and removed target/26-x-y PR should also be added to the "26-x-y" branch. target/25-x-y PR should also be added to the "25-x-y" branch. labels Aug 9, 2023
@codebytere
Copy link
Member

codebytere commented Aug 12, 2023

I think we should revert this - it's causing consistent failures on Linux cc @zcbenz

Example: https://app.circleci.com/pipelines/github/electron/electron/73291/workflows/c87fabd1-c799-4c0b-afb3-9c4830707e4f/jobs/1582308/tests

@TomaszMa
Copy link
Contributor Author

I think we should revert this - it's causing consistent failures on Linux cc @zcbenz

Example: https://app.circleci.com/pipelines/github/electron/electron/73291/workflows/c87fabd1-c799-4c0b-afb3-9c4830707e4f/jobs/1582308/tests

Test during integration passed, so or added test on linux is unstable, or something else break the test.
@codebytere I can look on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants