Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=760851 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 760851</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | <script type="application/javascript"> |
michael@0 | 12 | |
michael@0 | 13 | /** Test for Bug 760851 **/ |
michael@0 | 14 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 15 | |
michael@0 | 16 | // We need to skip all the interface constants. |
michael@0 | 17 | var keysToSkip = ["TYPE_NAVIGATE", "TYPE_RELOAD", "TYPE_RESERVED", |
michael@0 | 18 | "TYPE_BACK_FORWARD"]; |
michael@0 | 19 | |
michael@0 | 20 | // Testing window.performance is sufficient, because checkAttributesMatch is |
michael@0 | 21 | // recursive, so window.performance.navigation and window.performance.timing |
michael@0 | 22 | // get tested as well. |
michael@0 | 23 | var toTest = [window.performance]; |
michael@0 | 24 | |
michael@0 | 25 | function checkAttributesMatch(obj, jsonObj) { |
michael@0 | 26 | if (typeof(obj) !== "object") { |
michael@0 | 27 | throw "Expected obj to be of type \"object\". Test failed."; |
michael@0 | 28 | } |
michael@0 | 29 | if (typeof(jsonObj) !== "object") { |
michael@0 | 30 | is(false, "Expected object " + jsonObj + " to be of type object, but gotten otherwise"); |
michael@0 | 31 | } |
michael@0 | 32 | for (key in obj) { |
michael@0 | 33 | if (typeof(obj[key]) === "function" || keysToSkip.indexOf(key) > -1) |
michael@0 | 34 | continue; |
michael@0 | 35 | if (typeof(obj[key]) === "object") { |
michael@0 | 36 | checkAttributesMatch(obj[key], jsonObj[key]); |
michael@0 | 37 | continue; |
michael@0 | 38 | } |
michael@0 | 39 | is(jsonObj[key], obj[key], "values for " + obj + " key " + key + " should match"); |
michael@0 | 40 | } |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | function runTest() { |
michael@0 | 44 | toTest.forEach(function(testObj) { |
michael@0 | 45 | var jsonCopy = JSON.parse(JSON.stringify(testObj)); |
michael@0 | 46 | checkAttributesMatch(testObj, jsonCopy); |
michael@0 | 47 | }); |
michael@0 | 48 | SimpleTest.finish(); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | </script> |
michael@0 | 52 | </head> |
michael@0 | 53 | <body onload="runTest();"> |
michael@0 | 54 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=760851">Mozilla Bug 760851</a> |
michael@0 | 55 | <p id="display"></p> |
michael@0 | 56 | <div id="content" style="display: none"> |
michael@0 | 57 | <p></p> |
michael@0 | 58 | <p></p> |
michael@0 | 59 | <p></p> |
michael@0 | 60 | </div> |
michael@0 | 61 | <pre id="test"> |
michael@0 | 62 | </pre> |
michael@0 | 63 | </body> |
michael@0 | 64 | </html> |