| Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 if (objectInfo.isFunction) | 272 if (objectInfo.isFunction) | 
| 273 obj.prototype = this.getProperty(objectId, "prototype"); | 273 obj.prototype = this.getProperty(objectId, "prototype"); | 
| 274 | 274 | 
| 275 return obj; | 275 return obj; | 
| 276 } | 276 } | 
| 277 }; | 277 }; | 
| 278 | 278 | 
| 279 | 279 | 
| 280 /* Web request blocking */ | 280 /* Web request blocking */ | 
| 281 | 281 | 
| 282 var errorEvent = document.createEvent("Event"); | |
| 283 errorEvent.initEvent("error"); | |
| 284 | |
| 282 document.addEventListener("beforeload", function(event) | 285 document.addEventListener("beforeload", function(event) | 
| 283 { | 286 { | 
| 284 var type; | 287 var type; | 
| 285 | 288 | 
| 286 switch(event.target.localName) | 289 switch(event.target.localName) | 
| 287 { | 290 { | 
| 288 case "frame": | 291 case "frame": | 
| 289 case "iframe": | 292 case "iframe": | 
| 290 type = "sub_rame"; | 293 type = "sub_rame"; | 
| 291 break; | 294 break; | 
| (...skipping 19 matching lines...) Expand all Loading... | |
| 311 | 314 | 
| 312 if (!safari.self.tab.canLoad(event, { | 315 if (!safari.self.tab.canLoad(event, { | 
| 313 type: "webRequest", | 316 type: "webRequest", | 
| 314 payload: { | 317 payload: { | 
| 315 url: event.url, | 318 url: event.url, | 
| 316 type: type, | 319 type: type, | 
| 317 documentUrl: document.location.href, | 320 documentUrl: document.location.href, | 
| 318 isTopLevel: window == window.top | 321 isTopLevel: window == window.top | 
| 319 } | 322 } | 
| 320 })) | 323 })) | 
| 324 { | |
| 321 event.preventDefault(); | 325 event.preventDefault(); | 
| 326 | |
| 327 // Safari doesn't dispatch an "error" event when preventing an element | |
| 328 // from loading by cancelling the "beforeload" event. So we have to | |
| 329 // dispatch it manually. Otherwise element collapsing wouldn't work. | |
| 330 event.target.dispatchEvent(errorEvent); | |
| 
 
Wladimir Palant
2014/01/16 09:21:24
a) Does Safari really allow dispatching the same e
 
Sebastian Noack
2014/01/16 13:20:56
Apparently it does. But if that is non-standard, I
 
 | |
| 331 } | |
| 322 }, true); | 332 }, true); | 
| 323 | 333 | 
| 324 | 334 | 
| 325 /* API */ | 335 /* API */ | 
| 326 | 336 | 
| 327 ext.backgroundPage = { | 337 ext.backgroundPage = { | 
| 328 sendMessage: function(message, responseCallback) { | 338 sendMessage: function(message, responseCallback) { | 
| 329 _sendMessage( | 339 _sendMessage( | 
| 330 message, responseCallback, | 340 message, responseCallback, | 
| 331 safari.self.tab, safari.self, | 341 safari.self.tab, safari.self, | 
| 332 { | 342 { | 
| 333 documentUrl: document.location.href, | 343 documentUrl: document.location.href, | 
| 334 isTopLevel: window == window.top | 344 isTopLevel: window == window.top | 
| 335 } | 345 } | 
| 336 ); | 346 ); | 
| 337 }, | 347 }, | 
| 338 getWindow: function() | 348 getWindow: function() | 
| 339 { | 349 { | 
| 340 return proxy.getObject(0); | 350 return proxy.getObject(0); | 
| 341 } | 351 } | 
| 342 }; | 352 }; | 
| 343 | 353 | 
| 344 ext.onMessage = new ContentMessageEventTarget(); | 354 ext.onMessage = new ContentMessageEventTarget(); | 
| 345 })(); | 355 })(); | 
| OLD | NEW |