https://github.com/web-platform-tests/wpt
Raw File
Tip revision: f6f3c2a859b19ec6e7f273ed7a18bfdfb537a897 authored by David Quiroz Marin on 06 September 2018, 14:38:08 UTC
Remove ExtendedTextMetrics flag to launch canvas TextMetrics.
Tip revision: f6f3c2a
orientation-reading.html
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
  assert_true('type' in screen.orientation);
  assert_true('angle' in screen.orientation);
}, "Test screen.orientation properties");

test(() => {
  const type = screen.orientation.type;
  const angle = screen.orientation.angle;

  if (screen.width > screen.height) {
    assert_true(type == "landscape-primary" || type == "landscape-secondary");
  } else if (screen.width < screen.height) {
    assert_true(type == "portrait-primary" || type == "portrait-secondary");
  }

  assert_true(angle == 0 || angle == 90 || angle == 180 || angle == 270);
}, "Test screen.orientation default values.");

test(() => {
  const type = screen.orientation.type;
  const angle = screen.orientation.angle;

  screen.orientation.type = 'foo';
  screen.orientation.angle = 42;

  assert_equals(screen.orientation.type, type);
  assert_equals(screen.orientation.angle, angle);
}, "Test that screen.orientation properties are not writable");

test(() => {
  assert_equals(screen.orientation, screen.orientation);
}, "Test that screen.orientation is always the same object");

promise_test(async t => {
  const orientation = screen.orientation;
  const orientationType = screen.orientation.type;
  const orientationAngle = screen.orientation.angle;
  const orientationWatcher = new EventWatcher(t, orientation, "change");

  if (orientationType.includes("portrait")) {
    await orientation.lock("landscape-primary");
  } else {
    await orientation.lock("portrait-primary");
  }

  await orientationWatcher.wait_for("change");
  assert_equals(screen.orientation, orientation);
  assert_equals(screen.orientation.type, orientation.type);
  assert_equals(screen.orientation.angle, orientation.angle);
  assert_not_equals(screen.orientation.type, orientationType);
  assert_not_equals(screen.orientation.angle, orientationAngle);
  screen.orientation.unlock();
}, "Test that screen.orientation values change if the orientation changes");
</script>
back to top