| Index: third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
|
| diff --git a/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html b/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
|
| index c5a0829d700e3c6dbbc6df053ba4ccb50b6f3667..936b5547fc07bf3c8a24e65a19fa0e03cec2d4ec 100644
|
| --- a/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
|
| +++ b/third_party/WebKit/LayoutTests/sensor/ambient-light-sensor.html
|
| @@ -27,8 +27,8 @@ sensor_test(sensor => {
|
| let ambientLightSensor = new AmbientLightSensor();
|
| ambientLightSensor.start();
|
| return new Promise((resolve, reject) => {
|
| - ambientLightSensor.onstatechange = event => {
|
| - if(ambientLightSensor.state == 'errored') {
|
| + ambientLightSensor.onstatechange = () => {
|
| + if (ambientLightSensor.state == 'errored') {
|
| resolve();
|
| }
|
| };
|
| @@ -40,18 +40,17 @@ sensor_test(sensor => {
|
| let ambientLightSensor = new AmbientLightSensor();
|
| ambientLightSensor.start();
|
| return new Promise((resolve, reject) => {
|
| - ambientLightSensor.onerror = event => {
|
| + let wrapper = new CallbackWrapper(event => {
|
| assert_equals(ambientLightSensor.state, 'errored');
|
| - console.log(event.error.message);
|
| assert_equals(event.error.name, 'NotFoundError');
|
| ambientLightSensor.onerror = null;
|
| resolve();
|
| - };
|
| + }, reject);
|
|
|
| + ambientLightSensor.onerror = wrapper.callback();
|
| });
|
| }, 'Test that "onerror" is send when sensor is not supported.');
|
|
|
| -
|
| sensor_test(sensor => {
|
| let ambientLightSensor = new AmbientLightSensor({frequency: 560});
|
| ambientLightSensor.start();
|
| @@ -62,12 +61,14 @@ sensor_test(sensor => {
|
| return mockSensor.addConfigurationCalled(); })
|
| .then(mockSensor => {
|
| return new Promise((resolve, reject) => {
|
| - ambientLightSensor.onerror = event => {
|
| + let wrapper = new CallbackWrapper(event => {
|
| assert_equals(ambientLightSensor.state, 'errored');
|
| assert_equals(event.error.name, 'OperationError');
|
| ambientLightSensor.onerror = null;
|
| resolve();
|
| - };
|
| + }, reject);
|
| +
|
| + ambientLightSensor.onerror = wrapper.callback();
|
| });
|
| });
|
| return testPromise;
|
| @@ -80,18 +81,21 @@ sensor_test(sensor => {
|
| let testPromise = sensor.mockSensorProvider.getCreatedSensor()
|
| .then(mockSensor => { return mockSensor.addConfigurationCalled(); })
|
| .then(mockSensor => {
|
| - return new Promise((resolve, reject) => {
|
| - ambientLightSensor.onstatechange = event => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + return new Promise((resolve, reject) => {
|
| + let wrapper = new CallbackWrapper(event => {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
|
|
| - if (ambientLightSensor.state === 'active') {
|
| + if (ambientLightSensor.state == 'active') {
|
| let configuration = mockSensor.active_sensor_configurations_[0];
|
| assert_equals(configuration.frequency, 60);
|
| ambientLightSensor.stop();
|
| }
|
| - };
|
| + }, reject);
|
| +
|
| + ambientLightSensor.onstatechange = wrapper.callback();
|
| + ambientLightSensor.onerror = reject;
|
| });
|
| })
|
| .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
|
| @@ -106,11 +110,11 @@ sensor_test(sensor => {
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| ambientLightSensor.onstatechange = event => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
|
|
| - if (ambientLightSensor.state === 'active') {
|
| + if (ambientLightSensor.state == 'active') {
|
| ambientLightSensor.stop();
|
| }
|
| };
|
| @@ -129,11 +133,11 @@ sensor_test(sensor => {
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| ambientLightSensor.onstatechange = event => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
|
|
| - if (ambientLightSensor.state === 'active') {
|
| + if (ambientLightSensor.state == 'active') {
|
| ambientLightSensor.stop();
|
| }
|
| };
|
| @@ -155,14 +159,16 @@ sensor_test(sensor => {
|
| .then(mockSensor => {
|
| return new Promise((resolve, reject) => {
|
| ambientLightSensor.onstatechange = event => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
|
|
| - if (ambientLightSensor.state === 'active') {
|
| + if (ambientLightSensor.state == 'active') {
|
| ambientLightSensor.stop();
|
| }
|
| };
|
| +
|
| + ambientLightSensor.onerror = reject;
|
| });
|
| })
|
| .then(mockSensor => { return mockSensor.removeConfigurationCalled(); });
|
| @@ -179,17 +185,18 @@ sensor_test(sensor => {
|
| })
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| + let wrapper = new CallbackWrapper(event => {
|
| + assert_equals(event.reading.illuminance, kDefaultReadingValue);
|
| + ambientLightSensor.stop();
|
| + }, reject);
|
| +
|
| ambientLightSensor.onstatechange = event => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
| };
|
|
|
| - ambientLightSensor.onchange = e => {
|
| - assert_equals(e.reading.illuminance, kDefaultReadingValue);
|
| - ambientLightSensor.stop();
|
| - };
|
| -
|
| + ambientLightSensor.onchange = wrapper.callback();
|
| ambientLightSensor.onerror = reject;
|
| });
|
| })
|
| @@ -207,17 +214,18 @@ sensor_test(sensor => {
|
| })
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| - ambientLightSensor.onstatechange = () => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + ambientLightSensor.onstatechange = new CallbackWrapper(() => {
|
| + if (ambientLightSensor.state == 'idle') {
|
| assert_equals(ambientLightSensor.reading, null);
|
| resolve(mockSensor);
|
| }
|
| - }
|
| + }, reject).callback();
|
|
|
| - ambientLightSensor.onchange = e => {
|
| - assert_equals(e.reading.illuminance, kDefaultReadingValue);
|
| + ambientLightSensor.onchange = new CallbackWrapper(event => {
|
| + assert_equals(event.reading.illuminance, kDefaultReadingValue);
|
| ambientLightSensor.stop();
|
| - }
|
| + }, reject).callback();
|
| +
|
| ambientLightSensor.onerror = reject;
|
| });
|
| })
|
| @@ -254,7 +262,7 @@ sensor_test(sensor => {
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| ambientLightSensor.onstatechange = () => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
| }
|
|
|