Commit 0d13ed82 authored by Johannes Henkel's avatar Johannes Henkel Committed by aborovova@mozilla.com
Browse files

Bug 1966502 [wpt PR 52545] - Replace 2 tests with a subtest of...

Bug 1966502 [wpt PR 52545] - Replace 2 tests with a subtest of smoke/tentative/almost-soft-navigation.html.,

Automatic update from web-platform-tests
Replace 2 tests with a subtest of smoke/tentative/almost-soft-navigation.html.

replacestate.tentative.html is already covered with the replace-state
subtest, l. 59 in almost-soft-navigation.html in this change.

soft-navigation-no-url.tentative.html is getting covered with
noUrlPassedToPushState, in this change.

The tests I'm deleting make use of testSoftNavigationNotDetected in soft-navigation-helper.js, the replacements don't. Because the replacements don't wait for a timeout after each of these "almost softnavs" and run in the same doc and browser instance, they should be faster.

I'm also adding a global_test_id variable to make the
actual-softnavigation (which follows each attempted soft navigation)
go to a unique and predictable URL.

Change-Id: Id0d832540cc9293fbbeae2d99fce9a2e6d122a8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6545933
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Reviewed-by: default avatarMichal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1460312}

--

wpt-commits: 703a840544b310ffeef57ddd0cde54b1937d6151
wpt-pr: 52545

Differential Revision: https://phabricator.services.mozilla.com/D250205
parent 74429efa
Loading
Loading
Loading
Loading
+0 −30
Changes for testing/web-platform/tests/soft-navigation-heuristics/replacestate.tentative.html: 0 added lines, 30 removed lines.
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Detect soft navigation with replaceState.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/soft-navigation-helper.js"></script>
</head>
<body>
  <main id=main>
  <a id=link>Click me!</a>
  </main>
  <script>
    const link = document.getElementById("link");
    testSoftNavigationNotDetected({
      link: link,
      eventTarget: link,
      eventName: "click",
      eventHandler: async e => {
        const url = URL + "?" + counter;
        history.replaceState({}, '', url);
        await addImageToMain();
      },
      testName: "Should not detect soft navigation with just replaceState"});
  </script>
</body>
</html>
+18 −2
Changes for testing/web-platform/tests/soft-navigation-heuristics/smoke/tentative/almost-soft-navigation.html: 18 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,10 @@
    <script src="/resources/testdriver.js"></script>
    <script src="/resources/testdriver-vendor.js"></script>
    <script>
      // We append this value to the URL of actualSoftNavigation() to
      // identify the test, and to ensure it's unique.
      let global_test_id;

      // This click handler *does* cause a soft navigation, and *each test
      // ends with detecting it*. This is by design a very simple soft
      // navigation which we reliably detect - the same as in basic.html.
@@ -15,7 +19,7 @@
        const greeting = document.createElement("div");
        greeting.textContent = "Hello, World.";
        document.body.appendChild(greeting);
        history.pushState({}, "", "/actual-softnavigation");
        history.pushState({}, "", "/actual-softnavigation?" + global_test_id);
      }

      // This click handler won't cause a soft navigation, because it
@@ -58,6 +62,15 @@
        document.body.appendChild(greeting);
        history.replaceState({}, "", "/replace-state");
      }

      // This click handler won't cause a soft navigation, because it
      // doesn't pass a URL to pushState().
      function noUrlPassedToPushState() {
        const greeting = document.createElement("div");
        greeting.textContent = "Hello, World.";
        document.body.appendChild(greeting);
        history.pushState({}, "");
      }
    </script>
  </head>
  <body>
@@ -67,6 +80,7 @@
    <div id="no-dom-change" onclick="noDomChange()">Click here!</div>
    <div id="no-paint" onclick="noPaint()">Click here!</div>
    <div id="replace-state" onclick="replaceState()">Click here!</div>
    <div id="no-url-passed-to-push-state" onclick="noUrlPassedToPushState()">Click here!</div>

    <script>
      function test_template(test_id, description) {
@@ -75,12 +89,13 @@
            const entries = [];
            new PerformanceObserver((list, observer) => {
              entries.push(...list.getEntries());
              if (entries[entries.length - 1].name.endsWith("actual-softnavigation")) {
              if (entries[entries.length - 1].name.endsWith("actual-softnavigation?" + test_id)) {
                observer.disconnect();
                resolve(entries);
              }
            }).observe({ type: "soft-navigation" });
            if (test_driver) {
              global_test_id = test_id;
              test_driver.click(document.getElementById(test_id));
              test_driver.click(document.getElementById("actual-softnavigation"));
            }
@@ -99,6 +114,7 @@
      test_template("no-paint", "Doesn't paint because the element is hidden.");
      test_template("no-dom-change", "The DOM change is missing.");
      test_template("replace-state", "Uses replaceState() instead of pushState().");
      test_template("no-url-passed-to-push-state", "Doesn't pass a URL to pushState().");
    </script>
  </body>
</html>
+0 −31
Changes for testing/web-platform/tests/soft-navigation-heuristics/soft-navigation-no-url.tentative.html: 0 added lines, 31 removed lines.
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Detect simple soft navigation.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/soft-navigation-helper.js"></script>
</head>
<body>
  <main id=main>
  <a id=link>Click me!</a>
  </main>
  <script>
    const link = document.getElementById("link");
    testSoftNavigationNotDetected({
      eventHandler: url => {
        addTextToDivOnMain();
        history.pushState({}, '');
      },
      link: link,
      eventName: "click",
      eventTarget: link,
      testName: "Test that a soft navigation is not detected when a URL is not"
        + " passed to the history API."});
  </script>
</body>
</html>