Bug 1552309 - Avoid timing out with buggy behaviour in IndexedDB test, r=asuth

Ensure that the test returns a result in various error conditions
including databases not being defined, and databases() throwing an
exception. This avoids the test timing out as a failure mode and so
saves some runtime.

Differential Revision: https://phabricator.services.mozilla.com/D31523

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Graham 2019-07-30 15:54:56 +00:00
parent b2dea19e2d
commit d5479b6d88
2 changed files with 13 additions and 7 deletions

View File

@ -1,8 +1,7 @@
[idbfactory-databases-opaque-origin.html]
expected: TIMEOUT
[IDBFactory.databases() in sandboxed iframe should reject]
expected: NOTRUN
expected: FAIL
[IDBFactory.databases() in non-sandboxed iframe should not reject]
expected: TIMEOUT
expected: FAIL

View File

@ -31,9 +31,16 @@ function wait_for_message(iframe) {
const script =
'<script>' +
' window.onmessage = () => {' +
' indexedDB.databases().then(' +
' () => window.parent.postMessage({result: "no exception"}, "*"),' +
' ex => window.parent.postMessage({result: ex.name}, "*"));' +
' try { ' +
' if (!indexedDB || !indexedDB.databases) {' +
' window.parent.postMessage({result: "indexedDB.databases undefined"}, "*")' +
' }' +
' indexedDB.databases().then(' +
' () => window.parent.postMessage({result: "no exception"}, "*"),' +
' ex => window.parent.postMessage({result: ex.name}, "*"));' +
' } catch(e) { ' +
' window.parent.postMessage({result: e.name + " thrown, not rejected"}, "*")' +
' }'+
' };' +
'<\/script>';
@ -50,6 +57,6 @@ promise_test(async t => {
iframe.contentWindow.postMessage({}, '*');
const message = await wait_for_message(iframe);
assert_equals(message.result, 'SecurityError',
'Exception should be SecurityError');
'Promise should be rejected with SecurityError');
}, 'IDBFactory.databases() in sandboxed iframe should reject');
</script>