| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3  * Copyright (C) 2006-2015 Eyeo GmbH | 3  * Copyright (C) 2006-2015 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 50       document.removeEventListener("visibilitychange", onVisibilitychange); | 50       document.removeEventListener("visibilitychange", onVisibilitychange); | 
| 51     }; | 51     }; | 
| 52     document.addEventListener("visibilitychange", onVisibilitychange); | 52     document.addEventListener("visibilitychange", onVisibilitychange); | 
| 53   } | 53   } | 
| 54 | 54 | 
| 55 | 55 | 
| 56   /* Web requests */ | 56   /* Web requests */ | 
| 57 | 57 | 
| 58   document.addEventListener("beforeload", function(event) | 58   document.addEventListener("beforeload", function(event) | 
| 59   { | 59   { | 
| 60     var url = resolveURL(event.url); |  | 
| 61 |  | 
| 62     // we don't block non-HTTP requests anyway, so we can bail out | 60     // we don't block non-HTTP requests anyway, so we can bail out | 
| 63     // without asking the background page. This is even necessary | 61     // without asking the background page. This is even necessary | 
| 64     // because passing large data (like a photo encoded as data: URL) | 62     // because passing large data (like a photo encoded as data: URL) | 
| 65     // to the background page, freezes Safari. | 63     // to the background page, freezes Safari. | 
| 66     if (!/^https?:/.test(url)) | 64     if (/^(?!https?:)[\w-]+:/.test(event.url)) | 
| 67       return; | 65       return; | 
| 68 | 66 | 
| 69     var type = "other"; | 67     var type = "other"; | 
| 70     var eventName = "error"; | 68     var eventName = "error"; | 
| 71 | 69 | 
| 72     switch(event.target.localName) | 70     switch(event.target.localName) | 
| 73     { | 71     { | 
| 74       case "frame": | 72       case "frame": | 
| 75       case "iframe": | 73       case "iframe": | 
| 76         type = "sub_frame"; | 74         type = "sub_frame"; | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 89         break; | 87         break; | 
| 90       case "link": | 88       case "link": | 
| 91         if (/\bstylesheet\b/i.test(event.target.rel)) | 89         if (/\bstylesheet\b/i.test(event.target.rel)) | 
| 92           type = "stylesheet"; | 90           type = "stylesheet"; | 
| 93         break; | 91         break; | 
| 94     } | 92     } | 
| 95 | 93 | 
| 96     if (!safari.self.tab.canLoad( | 94     if (!safari.self.tab.canLoad( | 
| 97       event, { | 95       event, { | 
| 98         category: "webRequest", | 96         category: "webRequest", | 
| 99         url: url, | 97         url: event.url, | 
| 100         type: type, | 98         type: type, | 
| 101         pageId: documentInfo.pageId, | 99         pageId: documentInfo.pageId, | 
| 102         frameId: documentInfo.frameId | 100         frameId: documentInfo.frameId | 
| 103       } | 101       } | 
| 104     )) | 102     )) | 
| 105     { | 103     { | 
| 106       event.preventDefault(); | 104       event.preventDefault(); | 
| 107 | 105 | 
| 108       // Safari doesn't dispatch the expected events for elements that have been | 106       // Safari doesn't dispatch the expected events for elements that have been | 
| 109       // prevented from loading by having their "beforeload" event cancelled. | 107       // prevented from loading by having their "beforeload" event cancelled. | 
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 422             messageProxy.handleResponse(event.message); | 420             messageProxy.handleResponse(event.message); | 
| 423             break; | 421             break; | 
| 424           case "proxyCallback": | 422           case "proxyCallback": | 
| 425             backgroundPageProxy.handleCallback(event.message); | 423             backgroundPageProxy.handleCallback(event.message); | 
| 426             break; | 424             break; | 
| 427         } | 425         } | 
| 428       } | 426       } | 
| 429     } | 427     } | 
| 430   }); | 428   }); | 
| 431 })(); | 429 })(); | 
| OLD | NEW | 
|---|