From bb52d2d7eb51350e50a9fca71725cf71f18488d1 Mon Sep 17 00:00:00 2001 From: Danyao Wang Date: Wed, 15 Jan 2020 11:49:51 +0000 Subject: [PATCH] Bug 1608974 [wpt PR 21150] - Ignore unexpected MessageEvents, a=testonly Automatic update from web-platform-tests Ignore unexpected MessageEvents (#21150) -- wpt-commits: 2aad06617dd072cca5a1bcc6d0fc624934c689a4 wpt-pr: 21150 --- .../removing-allowpaymentrequest.https.sub.html | 3 +++ .../setting-allowpaymentrequest-timing.https.sub.html | 6 +++++- .../setting-allowpaymentrequest.https.sub.html | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/testing/web-platform/tests/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html b/testing/web-platform/tests/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html index b0e0cbacbf2e..64baebb50246 100644 --- a/testing/web-platform/tests/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html +++ b/testing/web-platform/tests/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html @@ -27,6 +27,9 @@ async_test((t) => { }); window.onmessage = t.step_func((e) => { + // Ignore messages that are not part of the test. + if (e.source != iframe.contentWindow) return; + i++; if (i === 1) { // 5. This is the first message we receive, from the first load. diff --git a/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html b/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html index 45661de7e0de..a741296d5da7 100644 --- a/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html +++ b/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html @@ -22,11 +22,15 @@ async_test((t) => { iframe.contentWindow.postMessage('What is the result of new PaymentRequest(...)?', '*'); }); - window.onmessage = t.step_func_done((e) => { + window.onmessage = t.step_func((e) => { + // Ignore messages that are not part of the test. + if (e.source != iframe.contentWindow) return; + assert_equals(e.data.message, 'Exception'); assert_equals(4, e.data.details.length); // The last entry is the error stacktrace. Ignore it in comparison. assert_array_equals(e.data.details.slice(0, 3), [true /* ex instanceof DOMException */, DOMException.SECURITY_ERR, 'SecurityError']); + t.done(); }); document.body.appendChild(iframe); diff --git a/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html b/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html index 06f0c8479da9..c1d53a4bc261 100644 --- a/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html +++ b/testing/web-platform/tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html @@ -20,6 +20,9 @@ async_test((t) => { }); window.onmessage = t.step_func((e) => { + // Ignore messages that are not part of the test. + if (e.source != iframe.contentWindow) return; + i++; if (i === 1) { assert_equals(e.data.message, 'Exception', 'before navigation');