forked from mirrors/gecko-dev
MozReview-Commit-ID: KjIquC2PKKI --HG-- rename : testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits.html => testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits.https.html rename : testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys.html => testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys.https.html rename : testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_hkdf.html => testing/web-platform/tests/WebCryptoAPI/derive_bits_keys/test_hkdf.https.html rename : testing/web-platform/tests/WebCryptoAPI/digest/test_digest.html => testing/web-platform/tests/WebCryptoAPI/digest/test_digest.https.html rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_cbc.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_cbc.https.html rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_ctr.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_ctr.https.html rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm.https.html rename : testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep.html => testing/web-platform/tests/WebCryptoAPI/encrypt_decrypt/test_rsa_oaep.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-cbc.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-cbc.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-ctr.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_aes-ctr.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CBC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CBC.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CTR.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-CTR.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-GCM.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-GCM.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-KW.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_AES-KW.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDH.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDH.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDSA.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_ECDSA.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_HMAC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_HMAC.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-OAEP.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-OAEP.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-PSS.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSA-PSS.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_failures_RSASSA-PKCS1-v1_5.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CBC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CBC.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CTR.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-CTR.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-GCM.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-GCM.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-KW.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_AES-KW.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDH.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDH.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDSA.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_ECDSA.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_HMAC.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_HMAC.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSA-PSS.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSA-PSS.https.html rename : testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.html => testing/web-platform/tests/WebCryptoAPI/generateKey/test_successes_RSASSA-PKCS1-v1_5.https.html rename : testing/web-platform/tests/WebCryptoAPI/import_export/test_ec_importKey.html => testing/web-platform/tests/WebCryptoAPI/import_export/test_ec_importKey.https.html rename : testing/web-platform/tests/WebCryptoAPI/import_export/test_rsa_importKey.html => testing/web-platform/tests/WebCryptoAPI/import_export/test_rsa_importKey.https.html rename : testing/web-platform/tests/WebCryptoAPI/import_export/test_symmetric_importKey.html => testing/web-platform/tests/WebCryptoAPI/import_export/test_symmetric_importKey.https.html rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_ecdsa.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_ecdsa.https.html rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_hmac.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_hmac.https.html rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pkcs.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pkcs.https.html rename : testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pss.html => testing/web-platform/tests/WebCryptoAPI/sign_verify/test_rsa_pss.https.html rename : testing/web-platform/tests/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.html => testing/web-platform/tests/WebCryptoAPI/wrapKey_unwrapKey/test_wrapKey_unwrapKey.https.html rename : testing/web-platform/tests/html/browsers/windows/browsing-context-names/browsing-context-_blank.html => testing/web-platform/tests/html/browsers/windows/browsing-context-names/choose-_blank-001.html rename : testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/parent-iframe-3.html => testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/choose-_parent-003-iframe.html rename : testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/parent-iframe-2.html => testing/web-platform/tests/html/browsers/windows/browsing-context-names/resources/open-in-_parent.html rename : testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.https.html => testing/web-platform/tests/presentation-api/receiving-ua/support/idlharness_receiving-ua.html rename : testing/web-platform/tests/tools/LICENSE => testing/web-platform/tests/tools/wptrunner/LICENSE rename : testing/web-platform/tests/auxclick/auxclick_event-manual.html => testing/web-platform/tests/uievents/auxclick/auxclick_event-manual.html rename : testing/web-platform/tests/webrtc/rtcpeerconnection/rtcconfiguration-icecandidatepoolsize.html => testing/web-platform/tests/webrtc/RTCConfiguration-iceCandidatePoolSize.html rename : testing/web-platform/tests/webrtc/rtcpeerconnection/rtcpeerconnection-constructor.html => testing/web-platform/tests/webrtc/RTCPeerConnection-constructor.html rename : testing/web-platform/tests/webrtc/rtcpeerconnection/iceGatheringState.html => testing/web-platform/tests/webrtc/RTCPeerConnection-iceGatheringState.html rename : testing/web-platform/tests/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html => testing/web-platform/tests/webrtc/RTCPeerConnection-idl.html
250 lines
7.1 KiB
JavaScript
250 lines
7.1 KiB
JavaScript
'use strict';
|
|
|
|
if (self.importScripts) {
|
|
self.importScripts('/resources/testharness.js');
|
|
}
|
|
|
|
test(() => {
|
|
const ws = new WritableStream({});
|
|
const writer = ws.getWriter();
|
|
writer.releaseLock();
|
|
|
|
assert_throws(new TypeError(), () => writer.desiredSize, 'desiredSize should throw a TypeError');
|
|
}, 'desiredSize on a released writer');
|
|
|
|
test(() => {
|
|
const ws = new WritableStream({});
|
|
|
|
const writer = ws.getWriter();
|
|
|
|
assert_equals(writer.desiredSize, 1, 'desiredSize should be 1');
|
|
}, 'desiredSize initial value');
|
|
|
|
promise_test(() => {
|
|
const ws = new WritableStream({});
|
|
|
|
const writer = ws.getWriter();
|
|
|
|
writer.close();
|
|
|
|
return writer.closed.then(() => {
|
|
assert_equals(writer.desiredSize, 0, 'desiredSize should be 0');
|
|
});
|
|
}, 'desiredSize on a writer for a closed stream');
|
|
|
|
test(() => {
|
|
const ws = new WritableStream({
|
|
start(c) {
|
|
c.error();
|
|
}
|
|
});
|
|
|
|
const writer = ws.getWriter();
|
|
assert_equals(writer.desiredSize, null, 'desiredSize should be null');
|
|
}, 'desiredSize on a writer for an errored stream');
|
|
|
|
test(() => {
|
|
const ws = new WritableStream({});
|
|
|
|
const writer = ws.getWriter();
|
|
writer.close();
|
|
writer.releaseLock();
|
|
|
|
ws.getWriter();
|
|
}, 'ws.getWriter() on a closing WritableStream');
|
|
|
|
promise_test(() => {
|
|
const ws = new WritableStream({});
|
|
|
|
const writer = ws.getWriter();
|
|
return writer.close().then(() => {
|
|
writer.releaseLock();
|
|
|
|
ws.getWriter();
|
|
});
|
|
}, 'ws.getWriter() on a closed WritableStream');
|
|
|
|
test(() => {
|
|
const ws = new WritableStream({});
|
|
|
|
const writer = ws.getWriter();
|
|
writer.abort();
|
|
writer.releaseLock();
|
|
|
|
ws.getWriter();
|
|
}, 'ws.getWriter() on an aborted WritableStream');
|
|
|
|
promise_test(() => {
|
|
const ws = new WritableStream({
|
|
start(c) {
|
|
c.error();
|
|
}
|
|
});
|
|
|
|
const writer = ws.getWriter();
|
|
return writer.closed.then(
|
|
v => assert_unreached('writer.closed fulfilled unexpectedly with: ' + v),
|
|
() => {
|
|
writer.releaseLock();
|
|
|
|
ws.getWriter();
|
|
}
|
|
);
|
|
}, 'ws.getWriter() on an errored WritableStream');
|
|
|
|
promise_test(() => {
|
|
const ws = new WritableStream({});
|
|
|
|
const writer = ws.getWriter();
|
|
writer.releaseLock();
|
|
|
|
return writer.closed.then(
|
|
v => assert_unreached('writer.closed fulfilled unexpectedly with: ' + v),
|
|
closedRejection => {
|
|
assert_equals(closedRejection.name, 'TypeError', 'closed promise should reject with a TypeError');
|
|
return writer.ready.then(
|
|
v => assert_unreached('writer.ready fulfilled unexpectedly with: ' + v),
|
|
readyRejection => assert_equals(readyRejection, closedRejection,
|
|
'ready promise should reject with the same error')
|
|
);
|
|
}
|
|
);
|
|
}, 'closed and ready on a released writer');
|
|
|
|
promise_test(() => {
|
|
const promises = {};
|
|
const resolvers = {};
|
|
for (const methodName of ['start', 'write', 'close', 'abort']) {
|
|
promises[methodName] = new Promise(resolve => {
|
|
resolvers[methodName] = resolve;
|
|
});
|
|
}
|
|
|
|
// Calls to Sink methods after the first are implicitly ignored. Only the first value that is passed to the resolver
|
|
// is used.
|
|
class Sink {
|
|
start() {
|
|
// Called twice
|
|
resolvers.start(this);
|
|
}
|
|
|
|
write() {
|
|
resolvers.write(this);
|
|
}
|
|
|
|
close() {
|
|
resolvers.close(this);
|
|
}
|
|
|
|
abort() {
|
|
resolvers.abort(this);
|
|
}
|
|
}
|
|
|
|
const theSink = new Sink();
|
|
const ws = new WritableStream(theSink);
|
|
|
|
const writer = ws.getWriter();
|
|
|
|
writer.write('a');
|
|
writer.close();
|
|
|
|
const ws2 = new WritableStream(theSink);
|
|
const writer2 = ws2.getWriter();
|
|
writer2.abort();
|
|
|
|
return promises.start
|
|
.then(thisValue => assert_equals(thisValue, theSink, 'start should be called as a method'))
|
|
.then(() => promises.write)
|
|
.then(thisValue => assert_equals(thisValue, theSink, 'write should be called as a method'))
|
|
.then(() => promises.close)
|
|
.then(thisValue => assert_equals(thisValue, theSink, 'close should be called as a method'))
|
|
.then(() => promises.abort)
|
|
.then(thisValue => assert_equals(thisValue, theSink, 'abort should be called as a method'));
|
|
}, 'WritableStream should call underlying sink methods as methods');
|
|
|
|
promise_test(t => {
|
|
function functionWithOverloads() {}
|
|
functionWithOverloads.apply = () => assert_unreached('apply() should not be called');
|
|
functionWithOverloads.call = () => assert_unreached('call() should not be called');
|
|
const underlyingSink = {
|
|
start: functionWithOverloads,
|
|
write: functionWithOverloads,
|
|
close: functionWithOverloads,
|
|
abort: functionWithOverloads
|
|
};
|
|
// Test start(), write(), close().
|
|
const ws1 = new WritableStream(underlyingSink);
|
|
const writer1 = ws1.getWriter();
|
|
writer1.write('a');
|
|
writer1.close();
|
|
|
|
// Test abort().
|
|
const ws2 = new WritableStream(underlyingSink);
|
|
const writer2 = ws2.getWriter();
|
|
writer2.abort();
|
|
|
|
// Test abort() with a close underlying sink method present. (Historical; see
|
|
// https://github.com/whatwg/streams/issues/620#issuecomment-263483953 for what used to be
|
|
// tested here. But more coverage can't hurt.)
|
|
const ws3 = new WritableStream({
|
|
start: functionWithOverloads,
|
|
write: functionWithOverloads,
|
|
close: functionWithOverloads
|
|
});
|
|
const writer3 = ws3.getWriter();
|
|
writer3.abort();
|
|
|
|
return writer1.closed
|
|
.then(() => promise_rejects(t, new TypeError(), writer2.closed, 'writer2.closed should be rejected'))
|
|
.then(() => promise_rejects(t, new TypeError(), writer3.closed, 'writer3.closed should be rejected'));
|
|
}, 'methods should not not have .apply() or .call() called');
|
|
|
|
promise_test(() => {
|
|
const strategy = {
|
|
size() {
|
|
if (this !== undefined) {
|
|
throw new Error('size called as a method');
|
|
}
|
|
return 1;
|
|
}
|
|
};
|
|
|
|
const ws = new WritableStream({}, strategy);
|
|
const writer = ws.getWriter();
|
|
return writer.write('a');
|
|
}, 'WritableStream\'s strategy.size should not be called as a method');
|
|
|
|
promise_test(() => {
|
|
const ws = new WritableStream();
|
|
const writer1 = ws.getWriter();
|
|
assert_equals(undefined, writer1.releaseLock(), 'releaseLock() should return undefined');
|
|
const writer2 = ws.getWriter();
|
|
assert_equals(undefined, writer1.releaseLock(), 'no-op releaseLock() should return undefined');
|
|
// Calling releaseLock() on writer1 should not interfere with writer2. If it did, then the ready promise would be
|
|
// rejected.
|
|
return writer2.ready;
|
|
}, 'redundant releaseLock() is no-op');
|
|
|
|
promise_test(() => {
|
|
const events = [];
|
|
const ws = new WritableStream();
|
|
const writer = ws.getWriter();
|
|
return writer.ready.then(() => {
|
|
// Force the ready promise back to a pending state.
|
|
const writerPromise = writer.write('dummy');
|
|
const readyPromise = writer.ready.catch(() => events.push('ready'));
|
|
const closedPromise = writer.closed.catch(() => events.push('closed'));
|
|
writer.releaseLock();
|
|
return Promise.all([readyPromise, closedPromise]).then(() => {
|
|
assert_array_equals(events, ['ready', 'closed'], 'ready promise should fire before closed promise');
|
|
// Stop the writer promise hanging around after the test has finished.
|
|
return Promise.all([
|
|
writerPromise,
|
|
ws.abort()
|
|
]);
|
|
});
|
|
});
|
|
}, 'ready promise should fire before closed on releaseLock');
|
|
|
|
done();
|