OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Should match SSLBlockingPageCommands in ssl_blocking_page.cc. |
| 6 var CMD_DONT_PROCEED = 0; |
| 7 var CMD_PROCEED = 1; |
| 8 var CMD_FOCUS = 2; |
| 9 var CMD_MORE = 3; |
| 10 var CMD_RELOAD = 4; |
| 11 |
| 12 var keyPressState = 0; |
| 13 |
| 14 function $(o) { |
| 15 return document.getElementById(o); |
| 16 } |
| 17 |
| 18 function sendCommand(cmd) { |
| 19 window.domAutomationController.setAutomationId(1); |
| 20 window.domAutomationController.send(cmd); |
| 21 } |
| 22 |
| 23 // This allows errors to be skippped by typing "proceed" into the page. |
| 24 function keyPressHandler(e) { |
| 25 var sequence = 'proceed'; |
| 26 if (sequence.charCodeAt(keyPressState) == e.keyCode) { |
| 27 keyPressState++; |
| 28 if (keyPressState == sequence.length) { |
| 29 sendCommand(CMD_PROCEED); |
| 30 keyPressState = 0; |
| 31 } |
| 32 } else { |
| 33 keyPressState = 0; |
| 34 } |
| 35 } |
| 36 |
| 37 function sharedSetup() { |
| 38 document.addEventListener('contextmenu', function(e) { |
| 39 e.preventDefault(); |
| 40 }); |
| 41 document.addEventListener('keypress', keyPressHandler); |
| 42 } |
| 43 |
| 44 document.addEventListener('DOMContentLoaded', sharedSetup); |
OLD | NEW |