Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: safari/ext/content.js

Issue 29353237: Issue 4361 - Pass all parameters to initEvent (Closed)
Patch Set: load and error events shouldn't be cancelable Created Sept. 16, 2016, 1 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | safari/include.youtube.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function() 18 (function()
19 { 19 {
20 // the safari object is missing in frames created from javascript: URLs. 20 // the safari object is missing in frames created from javascript: URLs.
21 // So we have to fallback to the safari object from the parent frame. 21 // So we have to fallback to the safari object from the parent frame.
22 if (!("safari" in window)) 22 if (!("safari" in window))
23 window.safari = window.parent.safari; 23 window.safari = window.parent.safari;
24 24
25 25
26 /* Intialization */ 26 /* Intialization */
27 27
28 var beforeLoadEvent = document.createEvent("Event"); 28 var beforeLoadEvent = document.createEvent("Event");
29 beforeLoadEvent.initEvent("beforeload"); 29 beforeLoadEvent.initEvent("beforeload", false, true);
30 30
31 // Decide if we should use the new content blocker API or not. (Note when the 31 // Decide if we should use the new content blocker API or not. (Note when the
32 // API is used Safari breaks the canLoad function, making it either throw an 32 // API is used Safari breaks the canLoad function, making it either throw an
33 // exception or return true when used.) 33 // exception or return true when used.)
34 var usingContentBlockerAPI = true; 34 var usingContentBlockerAPI = true;
35 try 35 try
36 { 36 {
37 if (safari.self.tab.canLoad(beforeLoadEvent, 37 if (safari.self.tab.canLoad(beforeLoadEvent,
38 {category: "request", 38 {category: "request",
39 payload: {type: "prefs.get", 39 payload: {type: "prefs.get",
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // Safari doesn't dispatch the expected events for elements that have 147 // Safari doesn't dispatch the expected events for elements that have
148 // been prevented from loading by having their "beforeload" event 148 // been prevented from loading by having their "beforeload" event
149 // cancelled. That is a "load" event for blocked frames, and an "error" 149 // cancelled. That is a "load" event for blocked frames, and an "error"
150 // event for other blocked elements. We need to dispatch those events 150 // event for other blocked elements. We need to dispatch those events
151 // manually here to avoid breaking element collapsing and pages that 151 // manually here to avoid breaking element collapsing and pages that
152 // rely on those events. 152 // rely on those events.
153 setTimeout(function() 153 setTimeout(function()
154 { 154 {
155 var evt = document.createEvent("Event"); 155 var evt = document.createEvent("Event");
156 evt.initEvent(eventName); 156 evt.initEvent(eventName, false, false);
157 event.target.dispatchEvent(evt); 157 event.target.dispatchEvent(evt);
158 }); 158 });
159 } 159 }
160 }, true); 160 }, true);
161 } 161 }
162 162
163 163
164 /* Context menus */ 164 /* Context menus */
165 165
166 document.addEventListener("contextmenu", function(event) 166 document.addEventListener("contextmenu", function(event)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 }); 223 });
224 224
225 225
226 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ 226 /* Detecting extension reload/disable/uninstall (not supported on Safari) */
227 227
228 ext.onExtensionUnloaded = { 228 ext.onExtensionUnloaded = {
229 addListener: function() {}, 229 addListener: function() {},
230 removeListener: function() {} 230 removeListener: function() {}
231 }; 231 };
232 })(); 232 })();
OLDNEW
« no previous file with comments | « no previous file | safari/include.youtube.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld