1 description('Tests that updates to the orientation causes new events to fire.'); 2 3 var mockEvent; 4 function setMockOrientation(alpha, beta, gamma) { 5 mockEvent = {alpha: alpha, beta: beta, gamma: gamma}; 6 if (window.layoutTestController) 7 layoutTestController.setMockDeviceOrientation(true, mockEvent.alpha, true, mockEvent.beta, true, mockEvent.gamma); 8 else 9 debug('This test can not be run without the LayoutTestController'); 10 } 11 12 var deviceOrientationEvent; 13 function checkOrientation(event) { 14 deviceOrientationEvent = event; 15 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); 16 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); 17 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); 18 } 19 20 function firstListener(event) { 21 checkOrientation(event); 22 window.removeEventListener('deviceorientation', firstListener); 23 24 setMockOrientation(11.1, 22.2, 33.3); 25 window.addEventListener('deviceorientation', updateListener); 26 } 27 28 function updateListener(event) { 29 checkOrientation(event); 30 finishJSTest(); 31 } 32 33 setMockOrientation(1.1, 2.2, 3.3); 34 window.addEventListener('deviceorientation', firstListener); 35 36 window.jsTestIsAsync = true; 37 window.successfullyParsed = true; 38