| 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 94458f1d6a492ed8eb516af27c04e47e6fa60e77..79956291b47f1ff336ee255148e36d32dc13fb96 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(() => {
|
| + 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,19 @@ sensor_test(sensor => {
|
| })
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| - ambientLightSensor.onstatechange = event => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + let wrapper = new CallbackWrapper(() => {
|
| + assert_equals(ambientLightSensor.reading.illuminance,
|
| + kDefaultReadingValue);
|
| + ambientLightSensor.stop();
|
| + }, reject);
|
| +
|
| + ambientLightSensor.onstatechange = () => {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
| };
|
|
|
| - ambientLightSensor.onchange = () => {
|
| - assert_equals(ambientLightSensor.reading.illuminance, kDefaultReadingValue);
|
| - ambientLightSensor.stop();
|
| - };
|
| -
|
| + ambientLightSensor.onchange = wrapper.callback;
|
| ambientLightSensor.onerror = reject;
|
| });
|
| })
|
| @@ -207,17 +215,19 @@ 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 = () => {
|
| - assert_equals(ambientLightSensor.reading.illuminance, kDefaultReadingValue);
|
| + ambientLightSensor.onchange = new CallbackWrapper(() => {
|
| + assert_equals(ambientLightSensor.reading.illuminance,
|
| + kDefaultReadingValue);
|
| ambientLightSensor.stop();
|
| - }
|
| + }, reject).callback;
|
| +
|
| ambientLightSensor.onerror = reject;
|
| });
|
| })
|
| @@ -236,7 +246,8 @@ sensor_test(sensor => {
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| ambientLightSensor.onchange = () => {
|
| - if (ambientLightSensor.reading.illuminance == kDefaultReadingValue) {
|
| + if (ambientLightSensor.reading.illuminance
|
| + == kDefaultReadingValue) {
|
| resolve(mockSensor);
|
| }
|
| }
|
| @@ -254,7 +265,7 @@ sensor_test(sensor => {
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| ambientLightSensor.onstatechange = () => {
|
| - if (ambientLightSensor.state === 'idle') {
|
| + if (ambientLightSensor.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
| }
|
| @@ -282,12 +293,12 @@ sensor_test(sensor => {
|
| .then((mockSensor) => {
|
| return new Promise((resolve, reject) => {
|
| sensor1.onstatechange = event => {
|
| - if (sensor1.state === 'idle') {
|
| + if (sensor1.state == 'idle') {
|
| resolve(mockSensor);
|
| }
|
| };
|
|
|
| - sensor1.onchange = () => {
|
| + let wrapper = new CallbackWrapper(() => {
|
| // Reading value is correct.
|
| assert_equals(sensor1.reading.illuminance, kDefaultReadingValue);
|
|
|
| @@ -306,8 +317,9 @@ sensor_test(sensor => {
|
|
|
| // Cached reading remains.
|
| assert_equals(reading.illuminance, kDefaultReadingValue);
|
| - };
|
| + }, reject);
|
|
|
| + sensor1.onchange = wrapper.callback;
|
| sensor1.onerror = reject;
|
| sensor2.onerror = reject;
|
| });
|
|
|