1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/file_bug668513.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <title>Test file for Bug 668513</title> 1.8 +<script> 1.9 + var SimpleTest = opener.SimpleTest; 1.10 + var ok = opener.ok; 1.11 + var is = opener.is; 1.12 + 1.13 + function finish() { 1.14 + SimpleTest.finish(); 1.15 + close(); 1.16 + } 1.17 + 1.18 + function onload_test() 1.19 + { 1.20 + var win = frames[0]; 1.21 + ok(win.performance, 'Window.performance should be defined'); 1.22 + ok(win.performance.navigation, 'Window.performance.navigation should be defined'); 1.23 + var navigation = win.performance && win.performance.navigation; 1.24 + if (navigation === undefined) 1.25 + { 1.26 + // avoid script errors 1.27 + finish(); 1.28 + return; 1.29 + } 1.30 + 1.31 + // do this with a timeout to see the visuals of the navigations. 1.32 + setTimeout("nav_frame();", 100); 1.33 + } 1.34 + 1.35 + var step = 1; 1.36 + function nav_frame() 1.37 + { 1.38 + var navigation_frame = frames[0]; 1.39 + var navigation = navigation_frame.performance.navigation; 1.40 + switch (step) 1.41 + { 1.42 + case 1: 1.43 + { 1.44 + navigation_frame.location.href = 'bug570341_recordevents.html'; 1.45 + step++; 1.46 + break; 1.47 + } 1.48 + case 2: 1.49 + { 1.50 + is(navigation.type, navigation.TYPE_NAVIGATE, 1.51 + 'Expected window.performance.navigation.type == TYPE_NAVIGATE'); 1.52 + navigation_frame.history.back(); 1.53 + step++; 1.54 + break; 1.55 + } 1.56 + case 3: 1.57 + { 1.58 + is(navigation.type, navigation.TYPE_BACK_FORWARD, 1.59 + 'Expected window.performance.navigation.type == TYPE_BACK_FORWARD'); 1.60 + step++; 1.61 + navigation_frame.history.forward(); 1.62 + break; 1.63 + } 1.64 + case 4: 1.65 + { 1.66 + is(navigation.type, navigation.TYPE_BACK_FORWARD, 1.67 + 'Expected window.performance.navigation.type == TYPE_BACK_FORWARD'); 1.68 + navigation_frame.location.href = 'bug668513_redirect.html'; 1.69 + step++; 1.70 + break; 1.71 + } 1.72 + case 5: 1.73 + { 1.74 + is(navigation.type, navigation.TYPE_NAVIGATE, 1.75 + 'Expected timing.navigation.type as TYPE_NAVIGATE'); 1.76 + is(navigation.redirectCount, 1, 1.77 + 'Expected navigation.redirectCount == 1 on an server redirected navigation'); 1.78 + 1.79 + var timing = navigation_frame.performance && navigation_frame.performance.timing; 1.80 + if (timing === undefined) 1.81 + { 1.82 + // avoid script errors 1.83 + finish(); 1.84 + break; 1.85 + } 1.86 + ok(timing.navigationStart > 0, 'navigationStart should be > 0'); 1.87 + sequence = ['navigationStart', 'redirectStart', 'redirectEnd', 'fetchStart']; 1.88 + for (var j = 1; j < sequence.length; ++j) { 1.89 + var prop = sequence[j]; 1.90 + var prevProp = sequence[j-1]; 1.91 + ok(timing[prevProp] <= timing[prop], 1.92 + ['Expected ', prevProp, ' to happen before ', prop, 1.93 + ', got ', prevProp, ' = ', timing[prevProp], 1.94 + ', ', prop, ' = ', timing[prop]].join('')); 1.95 + } 1.96 + step++; 1.97 + finish(); 1.98 + } 1.99 + default: 1.100 + break; 1.101 + } 1.102 + } 1.103 +</script> 1.104 +</head> 1.105 +<body> 1.106 +<div id="frames"> 1.107 +<iframe name="child0" onload="onload_test();" src="navigation/blank.html"></iframe> 1.108 +</div> 1.109 +</body> 1.110 +</html>