1 description('Tests using null values for some of the event properties.'); 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( 8 null != mockEvent.alpha, null == mockEvent.alpha ? 0 : mockEvent.alpha, 9 null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta, 10 null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gamma); 11 else 12 debug('This test can not be run without the LayoutTestController'); 13 } 14 15 var deviceOrientationEvent; 16 function checkOrientation(event) { 17 deviceOrientationEvent = event; 18 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); 19 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); 20 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); 21 } 22 23 function firstListener(event) { 24 checkOrientation(event); 25 window.removeEventListener('deviceorientation', firstListener); 26 27 setMockOrientation(1.1, null, null); 28 window.addEventListener('deviceorientation', secondListener); 29 } 30 31 function secondListener(event) { 32 checkOrientation(event); 33 window.removeEventListener('deviceorientation', secondListener); 34 35 setMockOrientation(null, 2.2, null); 36 window.addEventListener('deviceorientation', thirdListener); 37 } 38 39 function thirdListener(event) { 40 checkOrientation(event); 41 window.removeEventListener('deviceorientation', thirdListener); 42 43 setMockOrientation(null, null, 3.3); 44 window.addEventListener('deviceorientation', fourthListener); 45 } 46 47 function fourthListener(event) { 48 checkOrientation(event); 49 finishJSTest(); 50 } 51 52 setMockOrientation(null, null, null); 53 window.addEventListener('deviceorientation', firstListener); 54 55 window.jsTestIsAsync = true; 56 window.successfullyParsed = true; 57