diff options
Diffstat (limited to 'LayoutTests/fast/dom/DeviceOrientation/script-tests')
4 files changed, 104 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/DeviceOrientation/script-tests/TEMPLATE.html new file mode 100644 index 0000000..b31963d --- /dev/null +++ b/LayoutTests/fast/dom/DeviceOrientation/script-tests/TEMPLATE.html @@ -0,0 +1,12 @@ +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="YOUR_JS_FILE_HERE"></script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/create-event.js b/LayoutTests/fast/dom/DeviceOrientation/script-tests/create-event.js new file mode 100644 index 0000000..0fe8774 --- /dev/null +++ b/LayoutTests/fast/dom/DeviceOrientation/script-tests/create-event.js @@ -0,0 +1,21 @@ +description("Tests that document.createEvent() works with DeviceOrientationEvent."); + +var event = document.createEvent('DeviceOrientationEvent'); + +shouldBeTrue("typeof event == 'object'"); + +shouldBeTrue("'type' in event"); +shouldBeTrue("'bubbles' in event"); +shouldBeTrue("'cancelable' in event"); +shouldBeTrue("'alpha' in event"); +shouldBeTrue("'beta' in event"); +shouldBeTrue("'gamma' in event"); + +shouldBeTrue("typeof event.type == 'string'"); +shouldBeTrue("typeof event.bubbles == 'boolean'"); +shouldBeTrue("typeof event.cancelable == 'boolean'"); +shouldBeTrue("typeof event.alpha == 'object'"); +shouldBeTrue("typeof event.beta == 'object'"); +shouldBeTrue("typeof event.gamma == 'object'"); + +window.successfullyParsed = true; diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js b/LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js new file mode 100644 index 0000000..2936e72 --- /dev/null +++ b/LayoutTests/fast/dom/DeviceOrientation/script-tests/optional-event-properties.js @@ -0,0 +1,40 @@ +description("Tests the optional properties of DeviceOrientationEvent. Each property should be null if not set, or set to null or undefined."); + +var event; + +evalAndLog("event = document.createEvent('DeviceOrientationEvent')"); +shouldBeTrue("event.alpha == null"); +shouldBeTrue("event.beta == null"); +shouldBeTrue("event.gamma == null"); + +evalAndLog("event.initDeviceOrientationEvent('', false, false, 0, 1, 2)"); +shouldBeTrue("event.alpha == 0"); +shouldBeTrue("event.beta == 1"); +shouldBeTrue("event.gamma == 2"); + +evalAndLog("event.initDeviceOrientationEvent()"); +shouldBeTrue("event.alpha == null"); +shouldBeTrue("event.beta == null"); +shouldBeTrue("event.gamma == null"); + +evalAndLog("event.initDeviceOrientationEvent('', false, false, [], [], [])"); +shouldBeTrue("event.alpha == 0"); +shouldBeTrue("event.beta == 0"); +shouldBeTrue("event.gamma == 0"); + +evalAndLog("event.initDeviceOrientationEvent('', false, false, undefined, undefined, undefined)"); +shouldBeTrue("event.alpha == null"); +shouldBeTrue("event.beta == null"); +shouldBeTrue("event.gamma == null"); + +evalAndLog("event.initDeviceOrientationEvent('', false, false, '', '', '')"); +shouldBeTrue("event.alpha == 0"); +shouldBeTrue("event.beta == 0"); +shouldBeTrue("event.gamma == 0"); + +evalAndLog("event.initDeviceOrientationEvent('', false, false, null, null, null)"); +shouldBeTrue("event.alpha == null"); +shouldBeTrue("event.beta == null"); +shouldBeTrue("event.gamma == null"); + +window.successfullyParsed = true; diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/window-property.js b/LayoutTests/fast/dom/DeviceOrientation/script-tests/window-property.js new file mode 100644 index 0000000..e7458b4 --- /dev/null +++ b/LayoutTests/fast/dom/DeviceOrientation/script-tests/window-property.js @@ -0,0 +1,31 @@ +description("Tests that the window.DeviceOrientationEvent and window.ondeviceorientation properties are present."); + +function hasDeviceOrientationEventProperty() +{ + for (var property in window) { + if (property == "DeviceOrientationEvent") + return true; + } + return false; +} + +shouldBeTrue("typeof window.DeviceOrientationEvent == 'function'"); +shouldBeTrue("hasDeviceOrientationEventProperty()"); +shouldBeTrue("'DeviceOrientationEvent' in window"); +shouldBeTrue("window.hasOwnProperty('DeviceOrientationEvent')"); + +function hasOnDeviceOrientationProperty() +{ + for (var property in window) { + if (property == "ondeviceorientation") + return true; + } + return false; +} + +shouldBeTrue("typeof window.ondeviceorientation == 'object'"); +shouldBeTrue("hasOnDeviceOrientationProperty()"); +shouldBeTrue("'ondeviceorientation' in window"); +shouldBeFalse("window.hasOwnProperty('ondeviceorientation')"); + +window.successfullyParsed = true; |