Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Common js for prerender loaders; defines the helper functions that put | 5 // Common js for prerender loaders; defines the helper functions that put |
| 6 // event handlers on prerenders and track the events for browser tests. | 6 // event handlers on prerenders and track the events for browser tests. |
| 7 | 7 |
| 8 // TODO(gavinp): Put more common loader logic in here. | 8 // TODO(gavinp): Put more common loader logic in here. |
| 9 | 9 |
| 10 // Currently only errors with the ordering of Prerender events are caught. | 10 // Currently only errors with the ordering of Prerender events are caught. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 } | 45 } |
| 46 | 46 |
| 47 function AddEventHandlersToLinkElement(link, index) { | 47 function AddEventHandlersToLinkElement(link, index) { |
| 48 link.addEventListener('webkitprerenderstart', | 48 link.addEventListener('webkitprerenderstart', |
| 49 PrerenderStartHandler.bind(null, index), false); | 49 PrerenderStartHandler.bind(null, index), false); |
| 50 link.addEventListener('webkitprerenderload', | 50 link.addEventListener('webkitprerenderload', |
| 51 PrerenderLoadHandler.bind(null, index), false); | 51 PrerenderLoadHandler.bind(null, index), false); |
| 52 link.addEventListener('webkitprerenderstop', | 52 link.addEventListener('webkitprerenderstop', |
| 53 PrerenderStopHandler.bind(null, index), false); | 53 PrerenderStopHandler.bind(null, index), false); |
| 54 } | 54 } |
| 55 | |
| 56 function AddPrerender(url, index) { | |
| 57 var link = document.createElement('link'); | |
| 58 link.rel = 'prerender'; | |
| 59 link.href = url; | |
| 60 AddEventHandlersToLinkElement(link, index); | |
| 61 document.body.appendChild(link); | |
| 62 return link; | |
| 63 } | |
| 64 | |
| 65 function Click() { | |
| 66 document.getElementById('toClick').dispatchEvent(new MouseEvent('click', { | |
| 67 view: window, | |
| 68 bubbles: true, | |
| 69 cancelable: true, | |
| 70 detail: 1 | |
|
mmenke
2013/12/16 17:48:43
What does detail do? Can we just get rid of it?
davidben
2013/12/16 18:07:04
Apparently it's the number of clicks for a mouse e
| |
| 71 })); | |
| 72 } | |
| 73 | |
| 74 function ClickTarget() { | |
| 75 var eventObject = new MouseEvent('click', { | |
| 76 view: window, | |
| 77 bubbles: true, | |
| 78 cancelable: true, | |
| 79 detail: 1 | |
| 80 }); | |
| 81 document.getElementById('toClickTarget').dispatchEvent(eventObject); | |
| 82 } | |
| 83 | |
| 84 function ShiftClick() { | |
| 85 document.getElementById('toClick').dispatchEvent(new MouseEvent('click', { | |
| 86 view: window, | |
| 87 bubbles: true, | |
| 88 cancelable: true, | |
| 89 detail: 1, | |
| 90 shiftKey: true | |
| 91 })); | |
| 92 } | |
| 93 | |
| 94 function CtrlClick() { | |
| 95 document.getElementById('toClick').dispatchEvent(new MouseEvent('click', { | |
| 96 view: window, | |
| 97 bubbles: true, | |
| 98 cancelable: true, | |
| 99 detail: 1, | |
| 100 ctrlKey: true | |
| 101 })); | |
| 102 } | |
| 103 | |
| 104 function CtrlShiftClick() { | |
| 105 document.getElementById('toClick').dispatchEvent(new MouseEvent('click', { | |
| 106 view: window, | |
| 107 bubbles: true, | |
| 108 cancelable: true, | |
| 109 detail: 1, | |
| 110 ctrlKey: true, | |
| 111 shiftKey: true | |
| 112 })); | |
| 113 } | |
| 114 | |
| 115 function MetaClick() { | |
| 116 document.getElementById('toClick').dispatchEvent(new MouseEvent('click', { | |
| 117 view: window, | |
| 118 bubbles: true, | |
| 119 cancelable: true, | |
| 120 detail: 1, | |
| 121 metaKey: true | |
| 122 })); | |
| 123 } | |
| 124 | |
| 125 function MetaShiftClick() { | |
| 126 document.getElementById('toClick').dispatchEvent(new MouseEvent('click', { | |
| 127 view: window, | |
| 128 bubbles: true, | |
| 129 cancelable: true, | |
| 130 detail: 1, | |
| 131 metaKey: true, | |
| 132 shiftKey: true | |
| 133 })); | |
| 134 } | |
| 135 | |
| 136 function WindowOpen() { | |
| 137 window.open(document.getElementById('toClick').href); | |
| 138 } | |
| OLD | NEW |