|
8 | 8 | <script src="/resources/testdriver.js"></script>
|
9 | 9 | <script src="/resources/testdriver-vendor.js"></script>
|
10 | 10 | <script>
|
| 11 | + // We append this value to the URL of actualSoftNavigation() to |
| 12 | + // identify the test, and to ensure it's unique. |
| 13 | + let global_test_id; |
| 14 | + |
11 | 15 | // This click handler *does* cause a soft navigation, and *each test
|
12 | 16 | // ends with detecting it*. This is by design a very simple soft
|
13 | 17 | // navigation which we reliably detect - the same as in basic.html.
|
14 | 18 | function actualSoftNavigation() {
|
15 | 19 | const greeting = document.createElement("div");
|
16 | 20 | greeting.textContent = "Hello, World.";
|
17 | 21 | document.body.appendChild(greeting);
|
18 |
| - history.pushState({}, "", "/actual-softnavigation"); |
| 22 | + history.pushState({}, "", "/actual-softnavigation?" + global_test_id); |
19 | 23 | }
|
20 | 24 |
|
21 | 25 | // This click handler won't cause a soft navigation, because it
|
|
58 | 62 | document.body.appendChild(greeting);
|
59 | 63 | history.replaceState({}, "", "/replace-state");
|
60 | 64 | }
|
| 65 | + |
| 66 | + // This click handler won't cause a soft navigation, because it |
| 67 | + // doesn't pass a URL to pushState(). |
| 68 | + function noUrlPassedToPushState() { |
| 69 | + const greeting = document.createElement("div"); |
| 70 | + greeting.textContent = "Hello, World."; |
| 71 | + document.body.appendChild(greeting); |
| 72 | + history.pushState({}, ""); |
| 73 | + } |
61 | 74 | </script>
|
62 | 75 | </head>
|
63 | 76 | <body>
|
|
67 | 80 | <div id="no-dom-change" onclick="noDomChange()">Click here!</div>
|
68 | 81 | <div id="no-paint" onclick="noPaint()">Click here!</div>
|
69 | 82 | <div id="replace-state" onclick="replaceState()">Click here!</div>
|
| 83 | + <div id="no-url-passed-to-push-state" onclick="noUrlPassedToPushState()">Click here!</div> |
70 | 84 |
|
71 | 85 | <script>
|
72 | 86 | function test_template(test_id, description) {
|
|
75 | 89 | const entries = [];
|
76 | 90 | new PerformanceObserver((list, observer) => {
|
77 | 91 | entries.push(...list.getEntries());
|
78 |
| - if (entries[entries.length - 1].name.endsWith("actual-softnavigation")) { |
| 92 | + if (entries[entries.length - 1].name.endsWith("actual-softnavigation?" + test_id)) { |
79 | 93 | observer.disconnect();
|
80 | 94 | resolve(entries);
|
81 | 95 | }
|
82 | 96 | }).observe({ type: "soft-navigation" });
|
83 | 97 | if (test_driver) {
|
| 98 | + global_test_id = test_id; |
84 | 99 | test_driver.click(document.getElementById(test_id));
|
85 | 100 | test_driver.click(document.getElementById("actual-softnavigation"));
|
86 | 101 | }
|
|
99 | 114 | test_template("no-paint", "Doesn't paint because the element is hidden.");
|
100 | 115 | test_template("no-dom-change", "The DOM change is missing.");
|
101 | 116 | test_template("replace-state", "Uses replaceState() instead of pushState().");
|
| 117 | + test_template("no-url-passed-to-push-state", "Doesn't pass a URL to pushState()."); |
102 | 118 | </script>
|
103 | 119 | </body>
|
104 | 120 | </html>
|
0 commit comments