1description('Tests that updates to the orientation causes new events to fire.'); 2 3var mockEvent; 4function 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 12var deviceOrientationEvent; 13function 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 20function 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 28function updateListener(event) { 29 checkOrientation(event); 30 finishJSTest(); 31} 32 33setMockOrientation(1.1, 2.2, 3.3); 34window.addEventListener('deviceorientation', firstListener); 35 36window.jsTestIsAsync = true; 37window.successfullyParsed = true; 38