Skip to content

Commit

Permalink
[cookie wpt] make tests more reliable
Browse files Browse the repository at this point in the history
Let's add the listener before setting the src.

Change-Id: I63f7507394301aeac86370331d03651ff1e62c16
Fixed: 352081166
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5709008
Reviewed-by: Dylan Cutler <[email protected]>
Auto-Submit: Ari Chivukula <[email protected]>
Commit-Queue: Ari Chivukula <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1327750}
  • Loading branch information
arichiv authored and chromium-wpt-export-bot committed Jul 15, 2024
1 parent 761ecbe commit 5ae728b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cookies/resources/cookie-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ async function getAndExpireCookiesForDefaultPathTest() {
try {
const iframe = document.createElement('iframe');
iframe.style = 'display: none';
iframe.src = '/cookies/resources/echo-cookie.html';
iframe.addEventListener('load', (e) => {
const win = e.target.contentWindow;
const iframeCookies = win.getCookies();
Expand All @@ -14,6 +13,7 @@ async function getAndExpireCookiesForDefaultPathTest() {
resolve(iframeCookies);
});
}, {once: true});
iframe.src = '/cookies/resources/echo-cookie.html';
document.documentElement.appendChild(iframe);
} catch (e) {
reject(e);
Expand All @@ -28,7 +28,6 @@ async function getAndExpireCookiesForRedirectTest(location) {
try {
const iframe = document.createElement('iframe');
iframe.style = 'display: none';
iframe.src = location;
const listener = (e) => {
if (typeof e.data == 'object' && 'cookies' in e.data) {
window.removeEventListener('message', listener);
Expand All @@ -40,6 +39,7 @@ async function getAndExpireCookiesForRedirectTest(location) {
iframe.addEventListener('load', (e) => {
e.target.contentWindow.postMessage('getAndExpireCookiesForRedirectTest', '*');
}, {once: true});
iframe.src = location;
document.documentElement.appendChild(iframe);
} catch (e) {
reject(e);
Expand Down

0 comments on commit 5ae728b

Please sign in to comment.