Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test file for Bug 668513</title> |
michael@0 | 5 | <script> |
michael@0 | 6 | var SimpleTest = opener.SimpleTest; |
michael@0 | 7 | var ok = opener.ok; |
michael@0 | 8 | var is = opener.is; |
michael@0 | 9 | |
michael@0 | 10 | function finish() { |
michael@0 | 11 | SimpleTest.finish(); |
michael@0 | 12 | close(); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | function onload_test() |
michael@0 | 16 | { |
michael@0 | 17 | var win = frames[0]; |
michael@0 | 18 | ok(win.performance, 'Window.performance should be defined'); |
michael@0 | 19 | ok(win.performance.navigation, 'Window.performance.navigation should be defined'); |
michael@0 | 20 | var navigation = win.performance && win.performance.navigation; |
michael@0 | 21 | if (navigation === undefined) |
michael@0 | 22 | { |
michael@0 | 23 | // avoid script errors |
michael@0 | 24 | finish(); |
michael@0 | 25 | return; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | // do this with a timeout to see the visuals of the navigations. |
michael@0 | 29 | setTimeout("nav_frame();", 100); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | var step = 1; |
michael@0 | 33 | function nav_frame() |
michael@0 | 34 | { |
michael@0 | 35 | var navigation_frame = frames[0]; |
michael@0 | 36 | var navigation = navigation_frame.performance.navigation; |
michael@0 | 37 | switch (step) |
michael@0 | 38 | { |
michael@0 | 39 | case 1: |
michael@0 | 40 | { |
michael@0 | 41 | navigation_frame.location.href = 'bug570341_recordevents.html'; |
michael@0 | 42 | step++; |
michael@0 | 43 | break; |
michael@0 | 44 | } |
michael@0 | 45 | case 2: |
michael@0 | 46 | { |
michael@0 | 47 | is(navigation.type, navigation.TYPE_NAVIGATE, |
michael@0 | 48 | 'Expected window.performance.navigation.type == TYPE_NAVIGATE'); |
michael@0 | 49 | navigation_frame.history.back(); |
michael@0 | 50 | step++; |
michael@0 | 51 | break; |
michael@0 | 52 | } |
michael@0 | 53 | case 3: |
michael@0 | 54 | { |
michael@0 | 55 | is(navigation.type, navigation.TYPE_BACK_FORWARD, |
michael@0 | 56 | 'Expected window.performance.navigation.type == TYPE_BACK_FORWARD'); |
michael@0 | 57 | step++; |
michael@0 | 58 | navigation_frame.history.forward(); |
michael@0 | 59 | break; |
michael@0 | 60 | } |
michael@0 | 61 | case 4: |
michael@0 | 62 | { |
michael@0 | 63 | is(navigation.type, navigation.TYPE_BACK_FORWARD, |
michael@0 | 64 | 'Expected window.performance.navigation.type == TYPE_BACK_FORWARD'); |
michael@0 | 65 | navigation_frame.location.href = 'bug668513_redirect.html'; |
michael@0 | 66 | step++; |
michael@0 | 67 | break; |
michael@0 | 68 | } |
michael@0 | 69 | case 5: |
michael@0 | 70 | { |
michael@0 | 71 | is(navigation.type, navigation.TYPE_NAVIGATE, |
michael@0 | 72 | 'Expected timing.navigation.type as TYPE_NAVIGATE'); |
michael@0 | 73 | is(navigation.redirectCount, 1, |
michael@0 | 74 | 'Expected navigation.redirectCount == 1 on an server redirected navigation'); |
michael@0 | 75 | |
michael@0 | 76 | var timing = navigation_frame.performance && navigation_frame.performance.timing; |
michael@0 | 77 | if (timing === undefined) |
michael@0 | 78 | { |
michael@0 | 79 | // avoid script errors |
michael@0 | 80 | finish(); |
michael@0 | 81 | break; |
michael@0 | 82 | } |
michael@0 | 83 | ok(timing.navigationStart > 0, 'navigationStart should be > 0'); |
michael@0 | 84 | sequence = ['navigationStart', 'redirectStart', 'redirectEnd', 'fetchStart']; |
michael@0 | 85 | for (var j = 1; j < sequence.length; ++j) { |
michael@0 | 86 | var prop = sequence[j]; |
michael@0 | 87 | var prevProp = sequence[j-1]; |
michael@0 | 88 | ok(timing[prevProp] <= timing[prop], |
michael@0 | 89 | ['Expected ', prevProp, ' to happen before ', prop, |
michael@0 | 90 | ', got ', prevProp, ' = ', timing[prevProp], |
michael@0 | 91 | ', ', prop, ' = ', timing[prop]].join('')); |
michael@0 | 92 | } |
michael@0 | 93 | step++; |
michael@0 | 94 | finish(); |
michael@0 | 95 | } |
michael@0 | 96 | default: |
michael@0 | 97 | break; |
michael@0 | 98 | } |
michael@0 | 99 | } |
michael@0 | 100 | </script> |
michael@0 | 101 | </head> |
michael@0 | 102 | <body> |
michael@0 | 103 | <div id="frames"> |
michael@0 | 104 | <iframe name="child0" onload="onload_test();" src="navigation/blank.html"></iframe> |
michael@0 | 105 | </div> |
michael@0 | 106 | </body> |
michael@0 | 107 | </html> |