Bug 1646239 [wpt PR 24177] - Add getWindowSegments JavaScript API, a=testonly
authorDaniel Libby <dlibby@microsoft.com>
Mon, 22 Jun 2020 10:44:30 +0000
changeset 600933 f468703d8535544aa322cf833519cb2f7eec8003
parent 600932 eae3eced148f41177408b1949e9f7c4707f26271
child 600934 f4c08ad7631b1da1a7315e05e371ee975c374ba1
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1646239, 24177, 2229668, 2246988, 780102
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1646239 [wpt PR 24177] - Add getWindowSegments JavaScript API, a=testonly Automatic update from web-platform-tests Add getWindowSegments JavaScript API This change builds on crrev.com/c/2229668 to plumb the window segment information from the content layer into Blink, where it is exposed via a JavaScript API. From RenderWidget, the root window segments are stored on the local WebFrameWidgetBase root, and returned via script through the FrameWidget interface. i2p: https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/_1_ljYsaqrU/qOoHJ7MhAgAJ Explainer: https://github.com/webscreens/window-segments/blob/master/EXPLAINER.md Change-Id: I9b80f189e41160fc490bd09191722cb20b7115e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246988 Commit-Queue: Daniel Libby <dlibby@microsoft.com> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Cr-Commit-Position: refs/heads/master@{#780102} -- wpt-commits: 565dbc0bd35f3c4d34ad8c3fac0593d64d85bae9 wpt-pr: 24177
testing/web-platform/tests/window-segments/getWindowSegments-iframes.tentative.sub.html
testing/web-platform/tests/window-segments/getWindowSegments.https.tentative.html
testing/web-platform/tests/window-segments/post-window-segments-sub-frame.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/window-segments/getWindowSegments-iframes.tentative.sub.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Window Segments: getWindowSegments() tentative</title>
+<!-- TODO: update link to W3C whenever specifications are ready -->
+<link rel="help" href="https://github.com/webscreens/window-segments/"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+iframe { zoom: 2; }
+</style>
+<script>
+"use strict";
+
+async_test((t) => {
+  let segments = window.getWindowSegments();
+  let responses = 0;
+  window.addEventListener("message", t.step_func((evt) => {
+    let desc = "Window segments of child frame for: " + evt.data.domain;
+    assert_equals(evt.data.length, segments.length,
+        desc + " must match in length.");
+    assert_equals(evt.data.x, segments[0].x, desc + " must match for x.");
+    assert_equals(evt.data.y, segments[0].y, desc + " must match for x.");
+    assert_equals(evt.data.width, segments[0].width,
+        desc + " must match for x.");
+    assert_equals(evt.data.height, segments[0].height,
+        desc + " must match for x.");
+
+    responses++;
+    if (responses == 2) {
+      t.done();
+    }
+  }));
+}, "Window segments of child frames (same or different domain) must match those of the main frame.");
+</script>
+
+
+<iframe src="http://{{domains[www1]}}:{{ports[http][0]}}/window-segments/post-window-segments-sub-frame.html"></iframe>
+<iframe src="post-window-segments-sub-frame.html"></iframe>
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/window-segments/getWindowSegments.https.tentative.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Window Segments: getWindowSegments() tentative</title>
+<!-- TODO: update link to W3C whenever specifications are ready -->
+<link rel="help" href="https://github.com/webscreens/window-segments/"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+"use strict";
+
+test(() => {
+  let segments = window.getWindowSegments();
+  assert_equals(segments.length, 1, "For a viewport not segmented, there must be a single window segment");
+  let segment = segments[0];
+  assert_equals(segment.x, 0, "A viewport with a single segment must have 0, 0 origin");
+  assert_equals(segment.y, 0, "A viewport with a single segment must have 0, 0 origin");
+  assert_equals(segment.width, window.innerWidth, "A viewport with a single segment must have a width in CSS pixels, matching window.innerWidth");
+  assert_equals(segment.height, window.innerHeight, "A viewport with a single segment must have a height in CSS pixels, matching window.innerHeight");
+}, "getWindowSegments() returns a single segment, equal to the layout viewport dimesions");
+</script>
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/window-segments/post-window-segments-sub-frame.html
@@ -0,0 +1,12 @@
+<script>
+let segments = getWindowSegments();
+
+parent.postMessage({
+    length: segments.length,
+    x: segments[0].x,
+    y: segments[0].y,
+    width: segments[0].width,
+    height: segments[0].height,
+    domain: document.domain,
+  }, "*");
+</script>