Update web-platform-tests to revision 3cb5a99e5521936fb8819de8aaba806050b84184

This commit is contained in:
WPT Sync Bot 2019-06-23 10:23:36 +00:00
parent 1d2c0ba0bc
commit c700482629
204 changed files with 5112 additions and 1445 deletions

View file

@ -12,7 +12,7 @@
1) Include <script src="./sms_provider.js"></script> in your test.
2) Set expectations
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
// mock behavior
})
3) Call navigator.sms.receive()
@ -24,8 +24,8 @@
Here are the symbols that are exposed to tests that need to be implemented
per engine:
- function getNextMessage(): the main/only function that can be mocked.
- function expect(): the main/only function that enables us to mock it
- function receive(): the main/only function that can be mocked.
- function expect(): the main/only function that enables us to mock it.
- enum State {kSuccess, kTimeout}: allows you to mock success/failures.
-->
@ -34,12 +34,10 @@
'use strict';
promise_test(async t => {
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
return Promise.resolve({
sms: {
content: "hello",
status: Status.kSuccess,
}
status: Status.kSuccess,
message: "hello",
});
});
@ -49,20 +47,16 @@ promise_test(async t => {
}, 'Basic usage');
promise_test(async t => {
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
return Promise.resolve({
sms: {
content: "hello1",
status: Status.kSuccess,
}
status: Status.kSuccess,
message: "hello1",
});
});
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
return Promise.resolve({
sms: {
content: "hello2",
status: Status.kSuccess,
}
status: Status.kSuccess,
message: "hello2",
});
});
@ -77,19 +71,15 @@ promise_test(async t => {
}, 'Handle multiple requests in different order.');
promise_test(async t => {
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
return Promise.resolve({
sms: {
status: Status.kTimeout
}
status: Status.kTimeout,
});
});
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
return Promise.resolve({
sms: {
content: "success",
status: Status.kSuccess
}
status: Status.kSuccess,
message: "success",
});
});
@ -109,11 +99,9 @@ promise_test(async t => {
}, 'Handle multiple requests with success and error.');
promise_test(async t => {
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
return Promise.resolve({
sms: {
status: Status.kTimeout,
}
status: Status.kTimeout,
});
});
@ -167,12 +155,10 @@ promise_test(async t => {
}, 'Should throw error with invalid timeout (NaN)');
promise_test(async t => {
await expect(getNextMessage).andReturn((timeout) => {
await expect(receive).andReturn((timeout) => {
return Promise.resolve({
sms: {
content: "hello",
status: Status.kSuccess,
}
status: Status.kSuccess,
message: "hello",
});
});

View file

@ -5,7 +5,7 @@ let interceptor = (async function() {
'/gen/mojo/public/mojom/base/big_buffer.mojom-lite.js',
'/gen/mojo/public/mojom/base/string16.mojom-lite.js',
'/gen/mojo/public/mojom/base/time.mojom-lite.js',
'/gen/third_party/blink/public/mojom/sms/sms_manager.mojom-lite.js',
'/gen/third_party/blink/public/mojom/sms/sms_receiver.mojom-lite.js',
].forEach(path => {
let script = document.createElement('script');
script.src = path;
@ -24,8 +24,8 @@ class SmsProvider {
this.returnValues = {}
}
getNextMessage(timeout) {
let call = this.returnValues.getNextMessage.shift();
receive(timeout) {
let call = this.returnValues.receive.shift();
if (!call) {
throw new Error("Unexpected call.");
}
@ -39,7 +39,7 @@ class SmsProvider {
}
}
function getNextMessage(timeout, callback) {
function receive(timeout, callback) {
throw new Error("expected to be overriden by tests");
}
@ -58,9 +58,9 @@ function intercept() {
let provider = new SmsProvider();
let interceptor = new MojoInterfaceInterceptor(
blink.mojom.SmsManager.$interfaceName);
blink.mojom.SmsReceiver.$interfaceName);
interceptor.oninterfacerequest = (e) => {
let impl = new blink.mojom.SmsManager(provider);
let impl = new blink.mojom.SmsReceiver(provider);
impl.bindHandle(e.handle);
}