| <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> |
| <script src="/js-test-resources/ui-helper.js"></script> |
| <script src="resources/util.js"></script> |
| </head> |
| <body onload="setTimeout(runTest, 0)"> |
| <div id="description">Tests that stored attributions cannot be converted in an ephemeral session.</div> |
| <a id="targetLink" href="http://localhost:8000/adClickAttribution/conversion-disabled-in-ephemeral-session.html?stepTwo" adcampaignid="3" addestination="http://localhost:8000">Link</a><br> |
| <div id="output"></div> |
| <script> |
| const currentTimeMillis = (new Date()).getTime(); |
| const highEntropyBits = currentTimeMillis - (Math.floor(currentTimeMillis / 1000000) * 1000000); |
| const nonce = highEntropyBits + "" + Math.floor(Math.random() * 100); |
| |
| prepareTest(); |
| |
| if (window.testRunner) |
| testRunner.setAdClickAttributionConversionURLForTesting("http://127.0.0.1:8000/adClickAttribution/resources/conversionReport.php?nonce=" + nonce); |
| |
| function activateElement(elementID) { |
| var element = document.getElementById(elementID); |
| var centerX = element.offsetLeft + element.offsetWidth / 2; |
| var centerY = element.offsetTop + element.offsetHeight / 2; |
| UIHelper.activateAt(centerX, centerY).then( |
| function () { |
| }, |
| function () { |
| document.getElementById("output").innerText = "FAIL Promise rejected."; |
| tearDownAndFinish(); |
| } |
| ); |
| } |
| |
| function appendIframe(url, onloadCallback) { |
| let iframeElement = document.createElement("iframe"); |
| iframeElement.src = url; |
| if (onloadCallback) |
| iframeElement.onload = onloadCallback; |
| document.body.appendChild(iframeElement); |
| } |
| |
| function appendConversionDataIframeAndFinish() { |
| testRunner.dumpAdClickAttribution(); |
| document.body.removeChild(document.getElementById("targetLink")); |
| |
| appendIframe("http://127.0.0.1:8000/adClickAttribution/resources/getConversionData.php?timeout_ms=1000&nonce=" + nonce, function() { |
| tearDownAndFinish(); |
| }); |
| } |
| |
| function runTest() { |
| if (window.testRunner) { |
| if (window.location.search === "?stepTwo") { |
| testRunner.setShouldSwapToEphemeralSessionOnNextNavigation(true); |
| window.location = "http://localhost:8000/adClickAttribution/conversion-disabled-in-ephemeral-session.html?stepThree"; |
| } else if (window.location.search === "?stepThree") { |
| let imageElement = document.createElement("img"); |
| imageElement.src = "https://127.0.0.1:8443/adClickAttribution/resources/redirectToConversion.php?conversionData=12&nonce=" + nonce; |
| imageElement.id = "pixel"; |
| imageElement.onerror = function() { |
| testRunner.setShouldSwapToDefaultSessionOnNextNavigation(true); |
| window.location = "http://localhost:8000/adClickAttribution/conversion-disabled-in-ephemeral-session.html?stepFour"; |
| }; |
| document.body.appendChild(imageElement); |
| } else if (window.location.search === "?stepFour") { |
| appendConversionDataIframeAndFinish(); |
| } else { |
| document.cookie = "cookieSetAsFirstParty=1; path=/"; |
| activateElement("targetLink"); |
| } |
| } else { |
| document.getElementById("output").innerText = "FAIL No testRunner."; |
| } |
| } |
| </script> |
| </body> |
| </html> |