• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
6var CMD_DONT_PROCEED = 0;
7var CMD_PROCEED = 1;
8var CMD_MORE = 2;
9var CMD_RELOAD = 3;
10var CMD_HELP = 4;
11
12var keyPressState = 0;
13
14function $(o) {
15  return document.getElementById(o);
16}
17
18function sendCommand(cmd) {
19  window.domAutomationController.setAutomationId(1);
20  window.domAutomationController.send(cmd);
21}
22
23// This allows errors to be skippped by typing "danger" into the page.
24function keyPressHandler(e) {
25  var sequence = 'danger';
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
37function sharedSetup() {
38  document.addEventListener('contextmenu', function(e) {
39    e.preventDefault();
40  });
41  document.addEventListener('keypress', keyPressHandler);
42}
43
44document.addEventListener('DOMContentLoaded', sharedSetup);
45