-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add tests for window.orientation API #55503
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
base: master
Are you sure you want to change the base?
Conversation
Tests for the window.orientation attribute and orientationchange event as defined in the Screen Orientation specification. - Tests basic attribute presence and types - Tests valid orientation values (-90, 0, 90, 180) - Tests onorientationchange event handler - Tests orientationchange event firing with programmatic orientation changes - Tests mapping between screen.orientation.angle and window.orientation - Tests multiple orientation changes and event firing
| const testCases = [ | ||
| { lock: "portrait", expectedValues: [0, 180] }, | ||
| { lock: "landscape", expectedValues: [90, -90] }, | ||
| { lock: "natural", expectedValues: [0, 90, -90, 180] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In https://compat.spec.whatwg.org/#dfn-window-orientation-angle,
0 represents the natural orientation
So I think natural should be 0 only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right, yes.
|
|
||
| // Test different orientation locks and verify window.orientation values | ||
| const testCases = [ | ||
| { lock: "portrait", expectedValues: [0, 180] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is mobile device, default is "portrait". But if Windows tablet, default may be "landscape" (Firefox supports orientation APIs on Window tablet). So it is incorrect for all situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will fix.
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <title>window.orientation API</title> | ||
| <link rel="help" href="https://w3c.github.io/screen-orientation/"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orientationchange event isn't referenced in Screen Orientation API now. Is https://compat.spec.whatwg.org/ better? This document is https://compat.spec.whatwg.org/#windoworientation-interface. Or will you add a document for window.orientation in Screen Orientation API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add it to screen orientation.
Tests for the window.orientation attribute and orientationchange event as defined in the Screen Orientation specification.