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

devtools package: fix switchToFrame function #5350

Merged
merged 2 commits into from May 6, 2020
Merged

devtools package: fix switchToFrame function #5350

merged 2 commits into from May 6, 2020

Conversation

takeyaqa
Copy link
Contributor

@takeyaqa takeyaqa commented May 2, 2020

Proposed changes

fixes #5345

Add tests

  • add switchToFrame(number) test to e2e protocol test suite.
  • add switchToFrame(null) test to e2e protocol test suite.

Fix codes

  • fix switchToFrame(number) to apply appropriate this value.
  • fix condition checking order to avoid reference null value.
  • fix val to avoid infinite loop.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Further comments

Reviewers: @webdriverio/project-committers

* add switchToFrame(number) test
* add switchToFram(null) test (currently skipping)
* fix switchToFrame(number ) to apply appropriate this value
* fix condition checking order to to avoid reference null value
* fix val to avoid infinite loop
@jsf-clabot
Copy link

jsf-clabot commented May 2, 2020

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@erwinheitzman erwinheitzman left a comment

Choose a reason for hiding this comment

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

Small comment added

@@ -32,7 +44,7 @@ export default async function switchToFrame ({ id }) {
* `page` has `frames` method while `frame` has `childFrames` method
*/
let getFrames = page.frames || page.childFrames
const childFrames = await getFrames()
const childFrames = await getFrames.apply(page)
Copy link
Member

Choose a reason for hiding this comment

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

Why not do getFrames(page)?

Copy link
Member

Choose a reason for hiding this comment

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

The method doesn't take arguments. @takeya0x86 is correct here we call the method without its scope.

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! 👍

@@ -32,7 +44,7 @@ export default async function switchToFrame ({ id }) {
* `page` has `frames` method while `frame` has `childFrames` method
*/
let getFrames = page.frames || page.childFrames
const childFrames = await getFrames()
const childFrames = await getFrames.apply(page)
Copy link
Member

Choose a reason for hiding this comment

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

The method doesn't take arguments. @takeya0x86 is correct here we call the method without its scope.

@christian-bromann
Copy link
Member

Build is currently broken due to #5369 .. let's wait until it gets merged so we can rebase. Thank you @takeya0x86 for providing a fix!

@christian-bromann
Copy link
Member

I will go ahead and merge this so I can include it in the next release.

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label May 6, 2020
@christian-bromann christian-bromann merged commit 107c26a into webdriverio:master May 6, 2020
@takeyaqa takeyaqa deleted the 5345_switch_to_frame branch May 6, 2020 20:03
@christian-bromann christian-bromann added backport-requested PRs with this label are considered to be applied to the last maintained version backported PRs with this label got backported to the last maintained version and removed backport-requested PRs with this label are considered to be applied to the last maintained version labels May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported PRs with this label got backported to the last maintained version PR: Bug Fix 🐛 PRs that contain bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

devtools protocol: browser.switchToFrame(null) causes a TypeError
4 participants