Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 category: "webRequest", | 97 category: "webRequest", |
98 url: url, | 98 url: url, |
99 type: type, | 99 type: type, |
100 pageId: documentInfo.pageId, | 100 pageId: documentInfo.pageId, |
101 frameId: documentInfo.frameId | 101 frameId: documentInfo.frameId |
102 } | 102 } |
103 )) | 103 )) |
104 { | 104 { |
105 event.preventDefault(); | 105 event.preventDefault(); |
106 | 106 |
107 // Safari doesn't dispatch an "error" event when preventing an element | 107 // Safari doesn't dispatch the expected events for elements that have been |
108 // from loading by cancelling the "beforeload" event. Starting with | 108 // prevented from loading by having their "beforeload" event cancelled. |
kzar
2014/11/24 16:54:50
Nitpick: This comment doesn't read very well start
Sebastian Noack
2014/11/24 17:13:20
Can you explain why it doesn't read well in your o
kzar
2014/11/25 11:27:33
The part "...it not even dispatches..." would be m
Sebastian Noack
2014/11/25 11:48:38
I used a sligthly modified version of your text. I
kzar
2014/11/25 12:06:53
Cool, reads great
| |
109 // Safari 8, it not even dispatches a "load" event for cancelled frames. | 109 // That is a "load" event for blocked frames, and an "error" event for |
110 // So we have to dispatch it manually. Otherwise, element collapsing | 110 // other blocked elements. We need to dispatch those events manually here |
111 // wouldn't work, and pages that rely on those events break. | 111 // to avoid breaking element collapsing and pages that rely on those event s. |
112 if (type != "sub_frame" || parseInt(navigator.userAgent.match(/\bVersion\/ (\d+)/)[1], 10) >= 8) | 112 setTimeout(function() |
kzar
2014/11/24 16:54:50
What if the user is using a version < 8, shouldn't
Sebastian Noack
2014/11/24 17:13:20
Yes, and it is. However, error events should only
kzar
2014/11/25 11:27:33
Ah I see, sorry.
| |
113 { | 113 { |
114 setTimeout(function() | 114 var evt = document.createEvent("Event"); |
115 { | 115 evt.initEvent(eventName); |
116 var evt = document.createEvent("Event"); | 116 event.target.dispatchEvent(evt); |
117 evt.initEvent(eventName); | 117 }, 0); |
118 event.target.dispatchEvent(evt); | |
119 }, 0); | |
120 } | |
121 } | 118 } |
122 }, true); | 119 }, true); |
123 | 120 |
124 | 121 |
125 /* Context menus */ | 122 /* Context menus */ |
126 | 123 |
127 document.addEventListener("contextmenu", function(event) | 124 document.addEventListener("contextmenu", function(event) |
128 { | 125 { |
129 var element = event.srcElement; | 126 var element = event.srcElement; |
130 safari.self.tab.setContextMenuEventUserInfo(event, { | 127 safari.self.tab.setContextMenuEventUserInfo(event, { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 messageProxy.handleResponse(event.message); | 422 messageProxy.handleResponse(event.message); |
426 break; | 423 break; |
427 case "proxyCallback": | 424 case "proxyCallback": |
428 backgroundPageProxy.handleCallback(event.message); | 425 backgroundPageProxy.handleCallback(event.message); |
429 break; | 426 break; |
430 } | 427 } |
431 } | 428 } |
432 } | 429 } |
433 }); | 430 }); |
434 })(); | 431 })(); |
LEFT | RIGHT |