1description("This tests support for the document.createTouch API."); 2 3shouldBeTrue('"createTouch" in document'); 4 5var box = document.createElement("div"); 6box.id = "box"; 7box.style.width = "100px"; 8box.style.height = "100px"; 9document.body.appendChild(box); 10 11var target = document.getElementById("box"); 12var touch = document.createTouch(window, target, 1, 100, 101, 102, 103); 13shouldBeNonNull("touch"); 14shouldBe("touch.target", "box"); 15shouldBe("touch.identifier", "1"); 16shouldBe("touch.pageX", "100"); 17shouldBe("touch.pageY", "101"); 18shouldBe("touch.screenX", "102"); 19shouldBe("touch.screenY", "103"); 20 21var emptyTouch = document.createTouch(); 22shouldBeNonNull("emptyTouch"); 23shouldBeNull("emptyTouch.target"); 24shouldBe("emptyTouch.identifier", "0"); 25shouldBe("emptyTouch.pageX", "0"); 26shouldBe("emptyTouch.pageY", "0"); 27shouldBe("emptyTouch.screenX", "0"); 28shouldBe("emptyTouch.screenY", "0"); 29 30// Try invoking with incorrect parameter types. 31var badParamsTouch = document.createTouch(function(x) { return x; }, 12, 'a', 'b', 'c', function(x) { return x; }, 104); 32shouldBeNonNull("badParamsTouch"); 33shouldBeNull("badParamsTouch.target"); 34shouldBe("badParamsTouch.identifier", "0"); 35shouldBe("badParamsTouch.pageX", "0"); 36shouldBe("badParamsTouch.pageY", "0"); 37shouldBe("badParamsTouch.screenX", "0"); 38shouldBe("badParamsTouch.screenY", "104"); 39 40successfullyParsed = true; 41isSuccessfullyParsed(); 42