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(chrome): lock test #105

Merged
merged 2 commits into from
Sep 22, 2022
Merged

Conversation

breautek
Copy link
Contributor

@breautek breautek commented Sep 22, 2022

Platforms affected

Browser

Motivation and Context

Fixes a failing test:

1) cordova-plugin-screen-orientation-tests.tests >> window.screen.orientation should successfully lock and unlock screen orientation
  - Expected 'landscape-primary' to match /^portrait-/.

Description

The fix isn't truly a fix, but I don't think this issue is fixable. Previously this worked when the browser had no screen orientation API I believe, but modern versions of browser does. Just because the API exists however doesn't mean it's usable. Chrome on desktop will have the API exists but attempting to use it will result with a DOMException stating that the device isn't supported for locking.

Additionally, testing this specific case is also problematic because the lock promise still gets resolved without rejection. You cannot catch or otherwise capture the DOMException. The DOMException is only ever printed to the JS console if you attempt to run the code without anything catching the promise (and the promise is then resolved later).

It's not something I really like, but I don't think we have a better option, and I think this is better than having a false negative test.

The old unit test still exists, but is hidden behind a isLockable flag. It's generally expected that mobile devices will have a working lock API, should the browser cordova app ever be loaded on a mobile browser, therefore isLockable is set to true if it is believed the test is running on a mobile device (based on some userAgent keywords). This is however untested because I don't think we have a way to test browser platform on a mobile device.

Testing

Ran cordova-paramedic manually.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@breautek breautek requested a review from erisu September 22, 2022 00:33
This was referenced Sep 22, 2022
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

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

LGTM

@erisu erisu changed the title Fix/chrome lock test fix(chrome): lock test Sep 22, 2022
@breautek breautek merged commit 98ec1cf into apache:master Sep 22, 2022
@breautek breautek deleted the fix/chrome-lock-test branch September 22, 2022 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants