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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 url: event.url, | 321 url: event.url, |
322 type: type, | 322 type: type, |
323 documentUrl: document.location.href, | 323 documentUrl: document.location.href, |
324 isTopLevel: window == window.top | 324 isTopLevel: window == window.top |
325 } | 325 } |
326 } | 326 } |
327 )) | 327 )) |
328 { | 328 { |
329 event.preventDefault(); | 329 event.preventDefault(); |
330 | 330 |
331 // Safari doesn't dispatch an "error" or "load" event when preventing an | 331 // Safari doesn't dispatch an "error" event when preventing an element |
332 // element from loading by cancelling the "beforeload" event. So we have | 332 // from loading by cancelling the "beforeload" event. So we have to |
333 // to dispatch it manually. Otherwise element collapsing wouldn't work. | 333 // dispatch it manually. Otherwise element collapsing wouldn't work. |
334 var evt = document.createEvent("Event"); | 334 if (type != "sub_frame") |
335 evt.initEvent(type == "sub_frame" ? "load" : "error"); | 335 { |
336 event.target.dispatchEvent(evt); | 336 var evt = document.createEvent("Event"); |
| 337 evt.initEvent("error"); |
| 338 event.target.dispatchEvent(evt); |
| 339 } |
337 } | 340 } |
338 }, true); | 341 }, true); |
339 | 342 |
340 | 343 |
341 /* API */ | 344 /* API */ |
342 | 345 |
343 ext.backgroundPage = { | 346 ext.backgroundPage = { |
344 sendMessage: function(message, responseCallback) | 347 sendMessage: function(message, responseCallback) |
345 { | 348 { |
346 _sendMessage( | 349 _sendMessage( |
(...skipping 18 matching lines...) Expand all Loading... |
365 // so we need to add it to the event's user info. | 368 // so we need to add it to the event's user info. |
366 document.addEventListener("contextmenu", function(event) | 369 document.addEventListener("contextmenu", function(event) |
367 { | 370 { |
368 var element = event.srcElement; | 371 var element = event.srcElement; |
369 safari.self.tab.setContextMenuEventUserInfo(event, { | 372 safari.self.tab.setContextMenuEventUserInfo(event, { |
370 srcUrl: ("src" in element) ? element.src : null, | 373 srcUrl: ("src" in element) ? element.src : null, |
371 tagName: element.localName | 374 tagName: element.localName |
372 }); | 375 }); |
373 }, false); | 376 }, false); |
374 })(); | 377 })(); |
OLD | NEW |