https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 5423d8eda208d09132bddd79710ef3e716746218 authored by Mike Pennisi on 12 September 2018, 23:30:20 UTC
Demonstrate on downstream fork
Tip revision: 5423d8e
onchange-event-subframe.html
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<iframe id="testIframe" sandbox="allow-scripts allow-same-origin"
  style="display:none" src="resources/iframe-listen-orientation-change.html">
</iframe>

<script>
promise_test(async t => {
  let orientations = [
    'portrait-primary',
    'portrait-secondary',
    'landscape-primary',
    'landscape-secondary'
  ];
  if (screen.orientation.type.includes('portrait')) {
    orientations = orientations.reverse();
  }
  const messageWatcher = new EventWatcher(t, window, "message");

  for (const orientation of orientations) {
    await screen.orientation.lock(orientation);
    const message = await messageWatcher.wait_for("message");
    assert_equals(message.data, orientation, "subframe receives orientation change event");
  }
  screen.orientation.unlock();
}, "Test subframes receive orientation change events");
</script>
back to top