Skip to content

Commit

Permalink
Replace some "promise_rejects(t, 'SomeDOMError', stuff)" calls with p…
Browse files Browse the repository at this point in the history
…romise_rejects_dom.

This diff was generated by running:

  find . -type f -print0 | xargs -0 perl -pi -e "BEGIN { \$/ = undef; } s/promise_rejects\(([ \n]*[a-zA-Z_]+[ \n]*,[ \n]*)([\"'][A-Za-z_]*[\"']) *(, *.)/promise_rejects_dom(\1\2\3/gs"

in bash (doesn't work in tcsh, due to the $ inside "").
  • Loading branch information
bzbarsky authored and gsnedders committed Feb 10, 2020
1 parent 48f75c2 commit b7f2dd3
Show file tree
Hide file tree
Showing 152 changed files with 427 additions and 427 deletions.
2 changes: 1 addition & 1 deletion audio-output/setSinkId.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

promise_test(t => audio.setSinkId(""), "setSinkId on default audio output should always work");

promise_test(t => promise_rejects(t, "NotFoundError", audio.setSinkId("nonexistent_device_id")),
promise_test(t => promise_rejects_dom(t, "NotFoundError", audio.setSinkId("nonexistent_device_id")),
"setSinkId fails with NotFoundError on made up deviceid");

promise_test(async t => {
Expand Down
2 changes: 1 addition & 1 deletion background-fetch/fetch.https.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ backgroundFetchTest(async (test, backgroundFetch) => {

// Very large download total that will definitely exceed the quota.
const options = {downloadTotal: Number.MAX_SAFE_INTEGER};
await promise_rejects(
await promise_rejects_dom(
test, 'QUOTA_EXCEEDED_ERR',
backgroundFetch.fetch(registrationId, 'resources/feature-name.txt', options),
'This fetch should have thrown a quota exceeded error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
const header = 'Feature-Policy header {"battery" : []}';

promise_test(async t => {
await promise_rejects(t, 'NotAllowedError', navigator.getBattery());
await promise_rejects_dom(t, 'NotAllowedError', navigator.getBattery());
}, `${header} disallows the top-level document.`);

async_test(t => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
const path = location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1);
const src = 'https://{{domains[www1]}}:{{ports[https][0]}}' + path + 'support-iframe.html';
iframe = await load_iframe(iframe, src);
await promise_rejects(t, 'NotAllowedError', iframe.contentWindow.navigator.getBattery());
await promise_rejects_dom(t, 'NotAllowedError', iframe.contentWindow.navigator.getBattery());
}, "throw a 'NotAllowedError' when invoking navigator.getBattery() within cross-origin iframe");

</script>
2 changes: 1 addition & 1 deletion battery-status/battery-insecure-context.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<script>

promise_test(t => {
return promise_rejects(t, 'SecurityError', navigator.getBattery());
return promise_rejects_dom(t, 'SecurityError', navigator.getBattery());
}, "navigator.getBattery() shall throw a 'SecurityError' in an insecure context");

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ bluetooth_test(async (t) => {

const typed_array = Uint8Array.of(1, 2);
detachBuffer(typed_array.buffer);
await promise_rejects(
await promise_rejects_dom(
t, 'InvalidStateError', characteristic.writeValue(typed_array));

const array_buffer = Uint8Array.of(3, 4).buffer;
detachBuffer(array_buffer);
await promise_rejects(
await promise_rejects_dom(
t, 'InvalidStateError', characteristic.writeValue(array_buffer));
}, test_desc);
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ bluetooth_test(async (t) => {

const typed_array = Uint8Array.of(1, 2);
detachBuffer(typed_array.buffer);
await promise_rejects(
await promise_rejects_dom(
t, 'InvalidStateError', descriptor.writeValue(typed_array));

const array_buffer = Uint8Array.of(3, 4).buffer;
detachBuffer(array_buffer);
await promise_rejects(
await promise_rejects_dom(
t, 'InvalidStateError', descriptor.writeValue(array_buffer));
}, test_desc);
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
const invalidPngBlob = new Blob(['this text is not a valid png image'],
{type: "image/png"});
const clipboardItemInput = new ClipboardItem({'image/png' : invalidPngBlob});
await promise_rejects(t, "DataError",
await promise_rejects_dom(t, "DataError",
navigator.clipboard.write([clipboardItemInput]));
}, 'Verify write error on malformed data [image/png ClipboardItem]');
</script>
Expand Down
4 changes: 2 additions & 2 deletions clipboard-apis/clipboard-item.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
promise_test(async t => {
const item =
new ClipboardItem({'text/plain': blob, 'not a/real type': blob2});
promise_rejects(t, "NotFoundError", item.getType('type not in item'));
promise_rejects(t, "NotFoundError", item.getType('text/plain:subtype'));
promise_rejects_dom(t, "NotFoundError", item.getType('type not in item'));
promise_rejects_dom(t, "NotFoundError", item.getType('text/plain:subtype'));
}, "getType(DOMString type) rejects correctly when querying for missing type");
</script>
2 changes: 1 addition & 1 deletion content-security-policy/support/testharness-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function assert_service_worker_is_blocked(url, description) {
assert_equals(e.violatedDirective, "worker-src");
assert_equals(e.effectiveDirective, "worker-src");
})),
promise_rejects(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url }))
promise_rejects_dom(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url }))
]);
}, description);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(function(t) {
return promise_rejects(t, "NotSupportedError",
return promise_rejects_dom(t, "NotSupportedError",
navigator.credentials.create());
}, "navigator.credentials.create() with no argument.");

promise_test(function(t) {
return promise_rejects(t, "NotSupportedError",
return promise_rejects_dom(t, "NotSupportedError",
navigator.credentials.create({}));
}, "navigator.credentials.create() with empty argument.");

Expand Down Expand Up @@ -88,7 +88,7 @@
provider: 'https://example.com/',
};

return promise_rejects(t, "NotSupportedError",
return promise_rejects_dom(t, "NotSupportedError",
navigator.credentials.create({
password: credential_data,
federated: federated_data,
Expand Down Expand Up @@ -129,7 +129,7 @@
}, "navigator.credentials.create() with bogus password, federated, and publicKey data");

promise_test(function(t) {
return promise_rejects(t, "NotSupportedError",
return promise_rejects_dom(t, "NotSupportedError",
navigator.credentials.create({bogus_key: "bogus data"}));
}, "navigator.credentials.create() with bogus data");
</script>
4 changes: 2 additions & 2 deletions css/css-animations/CSSAnimation-finished.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
div.style.animation = '';
getComputedStyle(div).animation;

await promise_rejects(t, 'AbortError', originalFinishedPromise,
await promise_rejects_dom(t, 'AbortError', originalFinishedPromise,
'finished promise is rejected with AbortError');

assert_not_equals(animation.finished, originalFinishedPromise,
Expand All @@ -55,7 +55,7 @@
div.style.animation = 'def 100s';
getComputedStyle(div).animation;

await promise_rejects(t, 'AbortError', originalFinishedPromise,
await promise_rejects_dom(t, 'AbortError', originalFinishedPromise,
'finished promise is rejected with AbortError');

assert_not_equals(animation.finished, originalFinishedPromise,
Expand Down
4 changes: 2 additions & 2 deletions css/css-animations/CSSAnimation-ready.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
div.style.animation = '';
getComputedStyle(div).animation;

await promise_rejects(t, 'AbortError', readyPromise,
await promise_rejects_dom(t, 'AbortError', readyPromise,
'ready promise is rejected with AbortError');
}, 'ready promise is rejected when an animation is canceled by resetting'
+ ' the animation property');
Expand All @@ -64,7 +64,7 @@
div.style.animation = 'def 100s';
getComputedStyle(div).animation;

await promise_rejects(t, 'AbortError', readyPromise,
await promise_rejects_dom(t, 'AbortError', readyPromise,
'ready promise is rejected with AbortError');
}, 'ready promise is rejected when an animation is canceled by updating'
+ ' the animation property');
Expand Down
2 changes: 1 addition & 1 deletion css/css-font-loading/font-face-reject.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
promise_test(function(t) {
var testFontFace = new FontFace('TestFontFace', 'local("nonexistentfont-9a1a9f78-c8d4-11e9-af16-448a5b2c326f")');
document.fonts.add(testFontFace);
return promise_rejects(t, 'NetworkError', testFontFace.loaded);
return promise_rejects_dom(t, 'NetworkError', testFontFace.loaded);
})
</script>
<body>
Expand Down
2 changes: 1 addition & 1 deletion css/css-fonts/format-specifiers-variations.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
if (!expectFail) {
return fontFace.load();
} else {
return promise_rejects(testDetails, "NetworkError", fontFace.load());
return promise_rejects_dom(testDetails, "NetworkError", fontFace.load());
}
}, (expectFail ? "Do not load" : "Load") + " Ahem with format " + formats[i], {
"format": formats[i]
Expand Down
2 changes: 1 addition & 1 deletion css/geometry/structured-serialization.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@

promise_test((t) => {
const object = document.getElementById('log').getClientRects();
return promise_rejects(t, "DataCloneError", clone(object));
return promise_rejects_dom(t, "DataCloneError", clone(object));
}, 'DOMRectList clone');0
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy-violation']}).observe();
});
await promise_rejects(t, "SecurityError",
await promise_rejects_dom(t, "SecurityError",
navigator.requestMediaKeySystemAccess("org.w3.clearkey",
[{
initDataTypes: ["webm"],
Expand Down
2 changes: 1 addition & 1 deletion feature-policy/reporting/midi-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy-violation']}).observe();
});
await promise_rejects(t, 'SecurityError', navigator.requestMIDIAccess(),
await promise_rejects_dom(t, 'SecurityError', navigator.requestMIDIAccess(),
"MIDI device access should not be allowed in this document.");
const [reports, observer] = await report;
check_report_format(reports, observer);
Expand Down
2 changes: 1 addition & 1 deletion feature-policy/reporting/picture-in-picture-reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
});
const videoElement = await loadVideo();
await test_driver.bless('picture-in-picture');
await promise_rejects(t, 'SecurityError', videoElement.requestPictureInPicture(),
await promise_rejects_dom(t, 'SecurityError', videoElement.requestPictureInPicture(),
"Picture-in-Picture should not be allowed in this document.");
const [reports, observer] = await report;
check_report_format(reports, observer);
Expand Down
2 changes: 1 addition & 1 deletion feature-policy/reporting/vr-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy-violation']}).observe();
});
await promise_rejects(t, 'SecurityError', navigator.getVRDisplays(),
await promise_rejects_dom(t, 'SecurityError', navigator.getVRDisplays(),
"VR device access should not be allowed in this document.");
const [reports, observer] = await report;
check_report_format(reports, observer);
Expand Down
2 changes: 1 addition & 1 deletion feature-policy/reporting/xr-reporting.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy-violation']}).observe();
});
await promise_rejects(t, 'SecurityError',
await promise_rejects_dom(t, 'SecurityError',
navigator.xr.isSessionSupported('immersive-vr'),
"XR spatial tracking should not be allowed in this document.");
const [reports, observer] = await report;
Expand Down
32 changes: 16 additions & 16 deletions fetch/api/abort/general.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ promise_test(async t => {

const fetchPromise = fetch('../resources/data.json', { signal });

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}, "Aborting rejects with AbortError");

promise_test(async t => {
Expand All @@ -44,7 +44,7 @@ promise_test(async t => {
mode: 'no-cors'
});

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}, "Aborting rejects with AbortError - no-cors");

// Test that errors thrown from the request constructor take priority over abort errors.
Expand Down Expand Up @@ -88,7 +88,7 @@ promise_test(async t => {

const fetchPromise = fetch(request);

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}, "Signal on request object");

promise_test(async t => {
Expand All @@ -101,7 +101,7 @@ promise_test(async t => {

const fetchPromise = fetch(requestFromRequest);

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}, "Signal on request object created from request object");

promise_test(async t => {
Expand All @@ -114,7 +114,7 @@ promise_test(async t => {

const fetchPromise = fetch(requestFromRequest);

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}, "Signal on request object created from request object, with signal on second request");

promise_test(async t => {
Expand All @@ -127,7 +127,7 @@ promise_test(async t => {

const fetchPromise = fetch(requestFromRequest);

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}, "Signal on request object created from request object, with signal on second request overriding another");

promise_test(async t => {
Expand All @@ -139,7 +139,7 @@ promise_test(async t => {

const fetchPromise = fetch(request, {method: 'POST'});

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}, "Signal retained after unrelated properties are overridden by fetch");

promise_test(async t => {
Expand Down Expand Up @@ -205,7 +205,7 @@ for (const bodyMethod of BODY_METHODS) {
Promise.resolve().then(() => log.push('next-microtask'))
]);

await promise_rejects(t, "AbortError", bodyPromise);
await promise_rejects_dom(t, "AbortError", bodyPromise);

assert_array_equals(log, [`${bodyMethod}-reject`, 'next-microtask']);
}, `response.${bodyMethod}() rejects if already aborted`);
Expand Down Expand Up @@ -252,7 +252,7 @@ promise_test(async t => {
}

for (const fetchPromise of fetches) {
await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}
}, "Already aborted signal can be used for many fetches");

Expand All @@ -278,7 +278,7 @@ promise_test(async t => {
}

for (const fetchPromise of fetches) {
await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);
}
}, "Signal can be used to abort other fetches, even if another fetch succeeded before aborting");

Expand Down Expand Up @@ -366,7 +366,7 @@ for (const bodyMethod of BODY_METHODS) {

controller.abort();

await promise_rejects(t, "AbortError", bodyPromise);
await promise_rejects_dom(t, "AbortError", bodyPromise);

const start = Date.now();

Expand Down Expand Up @@ -394,8 +394,8 @@ promise_test(async t => {

controller.abort();

await promise_rejects(t, "AbortError", reader.read());
await promise_rejects(t, "AbortError", reader.closed);
await promise_rejects_dom(t, "AbortError", reader.read());
await promise_rejects_dom(t, "AbortError", reader.closed);

// The connection won't close immediately, but it should close at some point:
const start = Date.now();
Expand Down Expand Up @@ -425,8 +425,8 @@ promise_test(async t => {

controller.abort();

await promise_rejects(t, "AbortError", reader.read());
await promise_rejects(t, "AbortError", reader.closed);
await promise_rejects_dom(t, "AbortError", reader.read());
await promise_rejects_dom(t, "AbortError", reader.closed);

// The connection won't close immediately, but it should close at some point:
const start = Date.now();
Expand Down Expand Up @@ -488,7 +488,7 @@ promise_test(async t => {
assert_equals(cancelReason.constructor, DOMException);
assert_equals(cancelReason.name, 'AbortError');

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);

const fetchErr = await fetchPromise.catch(e => e);

Expand Down
8 changes: 4 additions & 4 deletions fetch/api/abort/serviceworker-intercepted.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

const fetchPromise = w.fetch('data.json', { signal });

await promise_rejects(t, "AbortError", fetchPromise);
await promise_rejects_dom(t, "AbortError", fetchPromise);

await w.fetch('data.json?no-abort');

Expand Down Expand Up @@ -76,7 +76,7 @@
Promise.resolve().then(() => log.push('next-microtask'))
]);

await promise_rejects(t, "AbortError", bodyPromise);
await promise_rejects_dom(t, "AbortError", bodyPromise);

assert_array_equals(log, [`${bodyMethod}-reject`, 'next-microtask']);
}, `response.${bodyMethod}() rejects if already aborted`);
Expand All @@ -97,8 +97,8 @@

controller.abort();

await promise_rejects(t, "AbortError", reader.read());
await promise_rejects(t, "AbortError", reader.closed);
await promise_rejects_dom(t, "AbortError", reader.read());
await promise_rejects_dom(t, "AbortError", reader.closed);
}, "Stream errors once aborted.");
</script>
</body>
Expand Down
Loading

0 comments on commit b7f2dd3

Please sign in to comment.