Commit bebffe78 authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

Migrate a security layout test to use mojo mocks

Bug: 802815
Change-Id: I043daf9fb62c2a13fa6630173808a089e1c64c50
Reviewed-on: https://chromium-review.googlesource.com/1073947
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562602}
parent bf2d1570
CONSOLE WARNING: Application Cache is deprecated in non-secure contexts, and will be restricted to secure contexts in M69, around September 2018. Please consider migrating your application to HTTPS, and eventually shifting over to Service Workers. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 26: The devicemotion event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 31: The deviceorientation event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 36: getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 55: getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 68: getCurrentPosition() and watchPosition() no longer work on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 87: getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 431: The devicemotion event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
CONSOLE WARNING: line 431: The deviceorientation event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.
This is a testharness.js-based test.
PASS device motion
PASS device orientation
......
......@@ -6,6 +6,9 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/get-host-info.js"></script>
<script src="/resources/sensor-helpers.js"></script>
<script src="/gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="/gen/services/device/public/mojom/sensor_provider.mojom.js"></script>
<body>
<div id="target"></div>
......@@ -18,17 +21,46 @@ if (window.location.origin != get_host_info().UNAUTHENTICATED_ORIGIN) {
// Tests for APIs that are deprecated, but still allowed, on
// insecure origins
async_test(function() {
testRunner.setMockDeviceMotion(true, 0, true, 0, true, 0,
true, 0, true, 0, true, 0,
true, 0, true, 0, true, 0,
0);
window.addEventListener('devicemotion', this.step_func_done());
sensor_test(async sensor => {
const fakeAccelerometerData = [1, 2, 3];
const fakeLinearAccelerationData = [4, 5, 6];
const fakeGyroscopeData = [7, 8, 9];
setMockSensorDataForType(sensor, device.mojom.SensorType.ACCELEROMETER, fakeAccelerometerData);
setMockSensorDataForType(sensor, device.mojom.SensorType.LINEAR_ACCELERATION, fakeLinearAccelerationData);
setMockSensorDataForType(sensor, device.mojom.SensorType.GYROSCOPE, fakeGyroscopeData);
const radToDeg = 180 / Math.PI;
return waitForEvent(new DeviceMotionEvent('devicemotion', {
acceleration: {
x: fakeLinearAccelerationData[0],
y: fakeLinearAccelerationData[1],
z: fakeLinearAccelerationData[2],
},
accelerationIncludingGravity: {
x: fakeAccelerometerData[0],
y: fakeAccelerometerData[1],
z: fakeAccelerometerData[2],
},
rotationRate: {
alpha: fakeGyroscopeData[0] * radToDeg,
beta: fakeGyroscopeData[1] * radToDeg,
gamma: fakeGyroscopeData[2] * radToDeg,
},
interval: 16,
}));
}, 'device motion');
async_test(function() {
testRunner.setMockDeviceOrientation(11.1, 22.2, 33.3, true);
window.addEventListener('deviceorientation', this.step_func_done());
sensor_test(async sensor => {
const fakeOrientationData = [1.1, 2.2, 3.3];
setMockSensorDataForType(sensor, device.mojom.SensorType.RELATIVE_ORIENTATION_EULER_ANGLES, fakeOrientationData);
return waitForEvent(new DeviceOrientationEvent('deviceorientation', {
alpha: fakeOrientationData[2],
beta: fakeOrientationData[0],
gamma: fakeOrientationData[1],
absolute: false,
}));
}, 'device orientation');
// Tests for APIs that have been turned off on insecure origins
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment