1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1412485
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1412485</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 1412485 **/
SimpleTest.waitForExplicitFinish();
function testExistenceOfLegacyTouchAPIs(win, enabled) {
try {
var event = document.createEvent("TouchEvent");
ok(event instanceof TouchEvent, "Should be able to create TouchEvent using createEvent.");
} catch(ex) {
ok(true, "Shouldn't be able create TouchEvent using createEvent.");
}
var targets = [win, win.document, win.document.body];
for (target of targets) {
is("ontouchstart" in target, enabled, `ontouchstart on target [${enabled}].`);
is("ontouchend" in target, enabled, `ontouchend on target [${enabled}].`);
is("ontouchmove" in target, enabled, `ontouchmove on target [${enabled}].`);
is("ontouchcancel" in target, enabled, `ontouchcancel on target [${enabled}].`);
}
is("createTouch" in win.document, enabled, `createTouch on Document [${enabled}].`);
is("createTouchList" in win.document, enabled, `createTouchList on Document [${enabled}].`);
}
function test() {
// Test the defaults.
testExistenceOfLegacyTouchAPIs(window,
navigator.userAgent.includes("Android"));
// Test explicitly enabling touch APIs.
SpecialPowers.pushPrefEnv({"set": [["dom.w3c_touch_events.enabled", 1],
["dom.w3c_touch_events.legacy_apis.enabled", true]]},
function() {
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.onload = function() {
testExistenceOfLegacyTouchAPIs(iframe.contentWindow, true);
SimpleTest.finish();
}
});
}
</script>
</head>
<body onload="test()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1412485">Mozilla Bug 1412485</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>
|