test_ManifestProcessor_orientation.html (2291B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1079453 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1079453</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script src="common.js"></script> 12 <script> 13 /** 14 * orientation member 15 * https://w3c.github.io/manifest/#orientation-member 16 */ 17 "use strict"; 18 19 typeTests.forEach((type) => { 20 var expected = `Expect non-string orientation to be empty string : ${typeof type}.`; 21 data.jsonText = JSON.stringify({ 22 orientation: type, 23 }); 24 var result = processor.process(data); 25 is(result.orientation, undefined, expected); 26 }); 27 28 var validOrientations = [ 29 "any", 30 "natural", 31 "landscape", 32 "portrait", 33 "portrait-primary", 34 "portrait-secondary", 35 "landscape-primary", 36 "landscape-secondary", 37 "aNy", 38 "NaTuRal", 39 "LANDsCAPE", 40 "PORTRAIT", 41 "portrait-PRIMARY", 42 "portrait-SECONDARY", 43 "LANDSCAPE-primary", 44 "LANDSCAPE-secondary", 45 ]; 46 47 validOrientations.forEach((orientation) => { 48 var expected = `Expect orientation to be returned: ${orientation}.`; 49 data.jsonText = JSON.stringify({ orientation }); 50 var result = processor.process(data); 51 is(result.orientation, orientation.toLowerCase(), expected); 52 }); 53 54 var invalidOrientations = [ 55 "all", 56 "ANYMany", 57 "NaTuRalle", 58 "portrait-primary portrait-secondary", 59 "portrait-primary,portrait-secondary", 60 "any-natural", 61 "portrait-landscape", 62 "primary-portrait", 63 "secondary-portrait", 64 "landscape-landscape", 65 "secondary-primary", 66 ]; 67 68 invalidOrientations.forEach((orientation) => { 69 var expected = `Expect orientation to be empty string: ${orientation}.`; 70 data.jsonText = JSON.stringify({ orientation }); 71 var result = processor.process(data); 72 is(result.orientation, undefined, expected); 73 }); 74 75 // Trim tests 76 validOrientations.forEach((orientation) => { 77 var expected = `Expect trimmed orientation to be returned.`; 78 var expandedOrientation = `${seperators}${lineTerminators}${orientation}${lineTerminators}${seperators}`; 79 data.jsonText = JSON.stringify({ 80 orientation: expandedOrientation, 81 }); 82 var result = processor.process(data); 83 is(result.orientation, orientation.toLowerCase(), expected); 84 }); 85 </script> 86 </head>