| 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 311 |
| 312 if (!safari.self.tab.canLoad(event, { | 312 if (!safari.self.tab.canLoad(event, { |
| 313 type: "webRequest", | 313 type: "webRequest", |
| 314 payload: { | 314 payload: { |
| 315 url: event.url, | 315 url: event.url, |
| 316 type: type, | 316 type: type, |
| 317 documentUrl: document.location.href, | 317 documentUrl: document.location.href, |
| 318 isTopLevel: window == window.top | 318 isTopLevel: window == window.top |
| 319 } | 319 } |
| 320 })) | 320 })) |
| 321 { |
| 321 event.preventDefault(); | 322 event.preventDefault(); |
| 323 |
| 324 // Safari doesn't dispatch an "error" event when preventing an element |
| 325 // from loading by cancelling the "beforeload" event. So we have to |
| 326 // dispatch it manually. Otherwise element collapsing wouldn't work. |
| 327 var evt = document.createEvent("Event"); |
| 328 evt.initEvent(type == "sub_frame" ? "load" : "error"); |
| 329 event.target.dispatchEvent(evt); |
| 330 } |
| 322 }, true); | 331 }, true); |
| 323 | 332 |
| 324 | 333 |
| 325 /* API */ | 334 /* API */ |
| 326 | 335 |
| 327 ext.backgroundPage = { | 336 ext.backgroundPage = { |
| 328 sendMessage: function(message, responseCallback) { | 337 sendMessage: function(message, responseCallback) { |
| 329 _sendMessage( | 338 _sendMessage( |
| 330 message, responseCallback, | 339 message, responseCallback, |
| 331 safari.self.tab, safari.self, | 340 safari.self.tab, safari.self, |
| 332 { | 341 { |
| 333 documentUrl: document.location.href, | 342 documentUrl: document.location.href, |
| 334 isTopLevel: window == window.top | 343 isTopLevel: window == window.top |
| 335 } | 344 } |
| 336 ); | 345 ); |
| 337 }, | 346 }, |
| 338 getWindow: function() | 347 getWindow: function() |
| 339 { | 348 { |
| 340 return proxy.getObject(0); | 349 return proxy.getObject(0); |
| 341 } | 350 } |
| 342 }; | 351 }; |
| 343 | 352 |
| 344 ext.onMessage = new ContentMessageEventTarget(); | 353 ext.onMessage = new ContentMessageEventTarget(); |
| 345 })(); | 354 })(); |
| OLD | NEW |