Skip to content

Conversation

@marcoscaceres
Copy link
Contributor

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

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] },
Copy link
Member

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.

Copy link
Contributor Author

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] },
Copy link
Member

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.

Copy link
Contributor Author

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/">
Copy link
Member

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?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants