author | Dimi Lee <dlee@mozilla.com> |
Wed, 12 Aug 2020 09:11:01 +0000 | |
changeset 544393 | 1e2a698cb1870ac8fc161f1e0c23111d071384c1 |
parent 544392 | 0fa31c531db234a08df41ffe3c1236ff2007f2f7 |
child 544394 | fe8a43ec580c0772ad7e80ca72efdc379a30d351 |
push id | 124004 |
push user | dlee@mozilla.com |
push date | Wed, 12 Aug 2020 09:17:09 +0000 |
treeherder | autoland@1e2a698cb187 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | timhuang |
bugs | 1652244 |
milestone | 81.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/indexedDB/test/test_third_party.html +++ b/dom/indexedDB/test/test_third_party.html @@ -11,35 +11,31 @@ <script type="text/javascript"> const BEHAVIOR_ACCEPT = 0; const BEHAVIOR_REJECTFOREIGN = 1; const BEHAVIOR_REJECT = 2; const BEHAVIOR_LIMITFOREIGN = 3; const testData = [ - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true }, - { host: "http://example.com", cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true }, - { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true }, - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_ACCEPT, expectedResult: true }, + { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_ACCEPT, expectedResultFrame1: true, expectedResultFrame2: true }, + { host: "http://example.com", cookieBehavior: BEHAVIOR_ACCEPT, expectedResultFrame1: true, expectedResultFrame2: true }, + { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_ACCEPT, expectedResultFrame1: true, expectedResultFrame2: true }, - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECT, expectedResult: false }, - { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECT, expectedResult: false }, - { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECT, expectedResult: false }, - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECT, expectedResult: false }, + { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECT, expectedResultFrame1: false, expectedResultFrame2: false }, + { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECT, expectedResultFrame1: false, expectedResultFrame2: false }, + { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECT, expectedResultFrame1: false, expectedResultFrame2: false }, - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: true }, - { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: false }, - { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: false }, - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResult: true }, + { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: true, expectedResultFrame2: true }, + { host: "http://example.com", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, + { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_REJECTFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: true }, - { host: "http://example.com", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: false }, - { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: false }, - { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResult: true }, + { host: "http://" + window.location.host, cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: true, expectedResultFrame2: true }, + { host: "http://example.com", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, + { host: "http://sub1.test2.example.org:8000", cookieBehavior: BEHAVIOR_LIMITFOREIGN, expectedResultFrame1: false, expectedResultFrame2: true }, ]; const iframe1Path = window.location.pathname.replace("test_third_party.html", "third_party_iframe1.html"); const iframe2URL = "http://" + window.location.host + window.location.pathname.replace("test_third_party.html", @@ -62,31 +58,46 @@ source: "parent", href: iframe2URL, iframeUrl: testData[testIndex].host + iframe1Path, }, "*"); }; }); } + let testFrames = ["iframe1", "iframe2"]; function messageListener(event) { let message = JSON.parse(event.data); // TODO: This is an ad-hoc solution to get a useful assertion message. // It would be desirable that the test framework provides the ability // to capture context information and provide it on assertion failures, // automatically stringified. let testContext = `testData[${testIndex}] == ${JSON.stringify(testData[testIndex])}`; - is(message.source, "iframe", `Good source for ${testContext}`); - is(message.result, testData[testIndex].expectedResult, `Good result for ${testContext}`); + let idx = testFrames.indexOf(message.source); + if (idx != -1) { + testFrames.splice(idx, 1); + if (message.source == "iframe1") { + is(message.result, testData[testIndex].expectedResultFrame1, `Good result for ${testContext} iframe1`); + } else if (message.source == "iframe2") { + is(message.result, testData[testIndex].expectedResultFrame2, `Good result for ${testContext} iframe2`); + } + } else { + ok(false, 'Test has already received a message from ${message.source}'); + } + + if (testFrames.length > 0) { + return; + } openedWindow.close(); if (testIndex < testData.length - 1) { + testFrames = ["iframe1", "iframe2"]; testIndex++; openWindow(); return; } SimpleTest.finish(); }
--- a/dom/indexedDB/test/third_party_iframe1.html +++ b/dom/indexedDB/test/third_party_iframe1.html @@ -8,21 +8,41 @@ <script type="text/javascript"> function messageListener(event) { let message = JSON.parse(event.data); if (message.source == "parent") { document.getElementById("iframe2").src = message.href; } - else if (message.source == "iframe") { + else if (message.source == "iframe2") { parent.postMessage(event.data, "*"); } } + + function report(result) { + let message = { source: "iframe1" }; + message.result = result; + window.parent.postMessage(JSON.stringify(message), "*"); + } + + function runIndexedDBTest() { + window.addEventListener('message', messageListener); + + try { + let request = indexedDB.open(window.location.pathname, 1); + request.onsuccess = function(event) { + report(!!(event.target.result instanceof IDBDatabase)); + }; + } + catch (e) { + report(false); + } + } </script> </head> -<body onload="window.addEventListener('message', messageListener, false);"> +<body onload="runIndexedDBTest();"> <iframe id="iframe2"></iframe> </body> </html>
--- a/dom/indexedDB/test/third_party_iframe2.html +++ b/dom/indexedDB/test/third_party_iframe2.html @@ -3,17 +3,17 @@ http://creativecommons.org/publicdomain/zero/1.0/ --> <html> <head> <title>Indexed Database Test</title> <script type="text/javascript"> function report(result) { - let message = { source: "iframe" }; + let message = { source: "iframe2" }; message.result = result; window.parent.postMessage(JSON.stringify(message), "*"); } function runIndexedDBTest() { try { let request = indexedDB.open(window.location.pathname, 1); request.onsuccess = function(event) {