| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <script> | |
| 3 function expect(test, msg) { | |
| 4 if (test) | |
| 5 return true; | |
| 6 | |
| 7 log.innerText = 'FAIL: expected ' + msg; | |
| 8 testRunner.notifyDone(); | |
| 9 return false; | |
| 10 } | |
| 11 | |
| 12 function testBackspaceNavigatesBack() { | |
| 13 eventSender.keyDown('Backspace'); | |
| 14 | |
| 15 // We expected to navigate; set a timeout that causes the test | |
| 16 // to fail quickly if we didn't navigate. | |
| 17 setTimeout(function() { | |
| 18 expect(false, 'navigation back'); | |
| 19 }, 500); | |
| 20 } | |
| 21 | |
| 22 function doStep(step, location) { | |
| 23 // This function is called on each page load. | |
| 24 // 'step' increases with each page load, while 'location' is the query param
for the page load. | |
| 25 // Since we go back and forwards, we assert that 'location' is what we expec
t upon the entry to each step. | |
| 26 | |
| 27 switch (step) { | |
| 28 case 0: | |
| 29 document.location = '?test-start'; | |
| 30 break; | |
| 31 case 1: | |
| 32 if (!expect(location == 'test-start', 'navigation to test-start')) | |
| 33 return; | |
| 34 document.location = '?test-mac'; | |
| 35 break; | |
| 36 case 2: | |
| 37 if (!expect(location == 'test-mac', 'navigation to test-mac')) | |
| 38 return; | |
| 39 | |
| 40 internals.settings.setEditingBehavior('mac'); | |
| 41 testBackspaceNavigatesBack(); | |
| 42 | |
| 43 break; | |
| 44 case 3: | |
| 45 if (!expect(location == 'test-start', 'navigation back to test-start')) | |
| 46 return; | |
| 47 document.location = '?test-win'; | |
| 48 break; | |
| 49 case 4: | |
| 50 if (!expect(location == 'test-win', 'navigation to test-win')) | |
| 51 return; | |
| 52 | |
| 53 internals.settings.setEditingBehavior('win'); | |
| 54 testBackspaceNavigatesBack(); | |
| 55 | |
| 56 break; | |
| 57 case 5: | |
| 58 if (!expect(location == 'test-start', 'navigation back to test-start')) | |
| 59 return; | |
| 60 document.location = '?test-unix'; | |
| 61 break; | |
| 62 case 6: | |
| 63 if (!expect(location == 'test-unix', 'navigation to test-unix')) | |
| 64 return; | |
| 65 | |
| 66 // Test unix behavior: that backspace does not go back. | |
| 67 internals.settings.setEditingBehavior('unix'); | |
| 68 | |
| 69 // We expect backspace to *not* navigate. | |
| 70 // Start a navigation to the success page; if backspace causes us to go
back, | |
| 71 // it will cancel that navigation and navigate us elsewhere, causing the
test | |
| 72 // to fail. | |
| 73 document.location = '?test-complete'; | |
| 74 eventSender.keyDown('Backspace'); | |
| 75 | |
| 76 break; | |
| 77 case 7: | |
| 78 if (!expect(location == 'test-complete', 'navigation to test-complete')) | |
| 79 return; | |
| 80 log.innerText += 'PASS: test complete'; | |
| 81 sessionStorage.removeItem('step'); | |
| 82 testRunner.notifyDone(); | |
| 83 } | |
| 84 } | |
| 85 | |
| 86 window.onpageshow = function() { | |
| 87 if (!window.testRunner || !window.eventSender || !window.internals) { | |
| 88 log.innerText = | |
| 89 'This test requires eventSender, testRunner and window.internals. '
+ | |
| 90 'It cannot be run manually.'; | |
| 91 return; | |
| 92 } | |
| 93 if (!location.search) { | |
| 94 sessionStorage.step = 0; | |
| 95 testRunner.dumpAsText(); | |
| 96 testRunner.clearBackForwardList(); | |
| 97 testRunner.waitUntilDone(); | |
| 98 } | |
| 99 | |
| 100 setTimeout(function() { | |
| 101 doStep(sessionStorage.step++, location.search.substring(1)); | |
| 102 }, 0) | |
| 103 } | |
| 104 </script> | |
| 105 <body>This test passes if it says PASS below. | |
| 106 <div id=log></div> | |
| 107 </body> | |
| OLD | NEW |