| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <p> | 7 <p> |
| 8 Tests that width MQ feature is correct on zoom. | 8 Tests that width MQ feature is correct on zoom. |
| 9 </p> | 9 </p> |
| 10 <script> | 10 <script> |
| 11 // eventSender.zoomPageOut/In zooms with a fixed factor of 1.2 inste
ad | 11 // eventSender.zoomPageOut/In zooms with a fixed factor of 1.2 inste
ad |
| 12 // of the zoom levels of the actual browser. | 12 // of the zoom levels of the actual browser. |
| 13 | 13 |
| 14 function printMatch(match) { | |
| 15 return (match > 0) ? "matches " + match + "px." : "doesn't match
tested values."; | |
| 16 } | |
| 17 | |
| 18 function test() { | 14 function test() { |
| 19 shouldBeTrue("window.matchMedia('(width: " + window.innerWidth +
"px)').matches"); | 15 var minWidth = window.innerWidth - 1; |
| 20 if (window.matchMedia("(width: " + window.innerWidth + "px)").ma
tches) | 16 var maxWidth = window.innerWidth + 1; |
| 21 return; | 17 shouldBeTrue("window.matchMedia('(min-width: " + minWidth + "px)
').matches"); |
| 22 | 18 shouldBeTrue("window.matchMedia('(max-width: " + maxWidth + "px)
').matches"); |
| 23 var matches = 0 | |
| 24 for (var j = 0; j < window.innerWidth + 100; j++) { | |
| 25 if (window.matchMedia("(width: " + j + "px)").matches) { | |
| 26 matches = j; | |
| 27 break; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 debug("window.innerWidth is " + window.innerWidth + "px, but wid
th MQ feature " + printMatch(j)); | |
| 32 } | 19 } |
| 33 | 20 |
| 34 if (window.eventSender) { | 21 if (window.eventSender) { |
| 35 for (var i = 0; i < 5; i++) { | 22 for (var i = 0; i < 5; i++) { |
| 36 eventSender.zoomPageOut(); | 23 eventSender.zoomPageOut(); |
| 37 test(); | 24 test(); |
| 38 } | 25 } |
| 39 | 26 |
| 40 for (var i = 0; i < 10; i++) { | 27 for (var i = 0; i < 10; i++) { |
| 41 eventSender.zoomPageIn(); | 28 eventSender.zoomPageIn(); |
| 42 test(); | 29 test(); |
| 43 } | 30 } |
| 44 } | 31 } |
| 45 </script> | 32 </script> |
| 46 </body> | 33 </body> |
| 47 </html> | 34 </html> |
| OLD | NEW |