<!doctype html><html><head><metacharset="utf-8"/><title>No Detection of Almost Soft Navigations.</title><scriptsrc="/resources/testharness.js"></script><scriptsrc="/resources/testharnessreport.js"></script><scriptsrc="/resources/testdriver.js"></script><scriptsrc="/resources/testdriver-vendor.js"></script><scriptsrc="../../resources/soft-navigation-test-helper.js"></script><script>// We append this value to the URL of actualSoftNavigation() to// identify the test, and to ensure it's unique.letglobal_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.functionactualSoftNavigation(){constgreeting=document.createElement("div");greeting.textContent="Hello, World.";document.body.appendChild(greeting);history.pushState({},"","/actual-softnavigation?"+global_test_id);}// This click handler won't cause a soft navigation, because it// doesn't change the URL.functionnoUrlChange(){constgreeting=document.createElement("div");greeting.textContent="Hello, World.";document.body.appendChild(greeting);}// This click handler won't cause a soft navigation, because the// element isn't attached to the DOM.functiondomNotAttached(){constgreeting=document.createElement("div");greeting.textContent="Hello, World.";history.pushState({},"","/dom-not-attached");}// This click handler won't cause a soft navigation, because it// doesn't change the DOM.functionnoDomChange(){history.pushState({},"","/no-dom-change");}// This click handler won't cause a soft navigation, because it// doesn't paint, even though the element is attached to the DOM.functionnoPaint(){constgreeting=document.createElement("div");greeting.textContent="Hello, World.";greeting.style.display="none";document.body.appendChild(greeting);history.pushState({},"","/no-paint");}// This click handler won't cause a soft navigation, because it// uses history.replaceState() instead of history.pushState().functionreplaceState(){constgreeting=document.createElement("div");greeting.textContent="Hello, World.";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().functionnoUrlPassedToPushState(){constgreeting=document.createElement("div");greeting.textContent="Hello, World.";document.body.appendChild(greeting);history.pushState({},"");}</script></head><body><divid="actual-softnavigation"onclick="actualSoftNavigation()">Click here!</div><divid="no-url-change"onclick="noUrlChange()">Click here!</div><divid="dom-not-attached"onclick="domNotAttached()">Click here!</div><divid="no-dom-change"onclick="noDomChange()">Click here!</div><divid="no-paint"onclick="noPaint()">Click here!</div><divid="replace-state"onclick="replaceState()">Click here!</div><divid="no-url-passed-to-push-state"onclick="noUrlPassedToPushState()">Click here!</div><script>functiontest_template(test_id,description){promise_test(async(t)=>{constpromise=SoftNavigationTestHelper.getPerformanceEntries("soft-navigation",/*includeSoftNavigationObservations=*/false,/*minNumEntries=*/1,);if(test_driver){global_test_id=test_id;test_driver.click(document.getElementById(test_id));test_driver.click(document.getElementById("actual-softnavigation"));}consthelper=newSoftNavigationTestHelper(t);constentries=awaithelper.withTimeoutMessage(promise,"No soft navigation (test_id="+test_id+").",/*timeout=*/3000,);assert_equals(entries.length,1,"Expected single soft navigation (test_id="+test_id+").",);assert_equals(entries[0].name.replace(/.*\//,""),"actual-softnavigation?"+test_id,"Expected name ending in 'actual-softnavigation?"+test_id+"'",);},description);}test_template("no-url-change","The URL change is missing.");test_template("dom-not-attached","Creates an element but doesn't attach it to the DOM.");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>