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

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

Issue 4858514686083072: Don't dispatch a "load" event for blocked frames on Safari (Closed)
Patch Set: Created Feb. 25, 2014, 10:04 a.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 | no next file » | 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 <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
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
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 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld