Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of the URL Fixer, | 2 * This file is part of the URL Fixer, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * URL Fixer is free software: you can redistribute it and/or modify | 5 * URL Fixer 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 * URL Fixer is distributed in the hope that it will be useful, | 9 * URL Fixer 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 26 matching lines...) Expand all Loading... | |
37 this.shutdownHandlers.splice(index, 1); | 37 this.shutdownHandlers.splice(index, 1); |
38 } | 38 } |
39 }; | 39 }; |
40 | 40 |
41 let netErrorOverlay = null; | 41 let netErrorOverlay = null; |
42 | 42 |
43 function receivedNetErrorOverlay(message) | 43 function receivedNetErrorOverlay(message) |
44 { | 44 { |
45 let parser = Cc["@mozilla.org/xmlextras/domparser;1"] | 45 let parser = Cc["@mozilla.org/xmlextras/domparser;1"] |
46 .createInstance(Ci.nsIDOMParser); | 46 .createInstance(Ci.nsIDOMParser); |
47 netErrorOverlay = parser.parseFromString(message.data, "application/xml"); | 47 netErrorOverlay = parser.parseFromString(message.data, "application/xml"); |
Thomas Greiner
2016/03/08 12:34:43
Note that previously we were first loading the err
Wladimir Palant
2016/03/08 14:37:48
Yes. There is a check for netErrorOverlay in the e
| |
48 } | 48 } |
49 | 49 |
50 function shutdown(message) | 50 function shutdown(message) |
51 { | 51 { |
52 if (message.data == Components.stack.filename && !onShutdown.done) | 52 if (message.data == Components.stack.filename && !onShutdown.done) |
53 { | 53 { |
54 onShutdown.done = true; | 54 onShutdown.done = true; |
55 for (let i = onShutdown.shutdownHandlers.length - 1; i >= 0; i --) | 55 for (let i = onShutdown.shutdownHandlers.length - 1; i >= 0; i --) |
56 { | 56 { |
57 try | 57 try |
58 { | 58 { |
59 onShutdown.shutdownHandlers[i](); | 59 onShutdown.shutdownHandlers[i](); |
60 } | 60 } |
61 catch (e) | 61 catch (e) |
62 { | 62 { |
63 Cu.reportError(e); | 63 Cu.reportError(e); |
64 } | 64 } |
65 } | 65 } |
66 onShutdown.shutdownHandlers = null; | 66 onShutdown.shutdownHandlers = null; |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 function onDocumentCreated(subject, topic, data) | 70 function onDocumentCreated(subject, topic, data) |
71 { | 71 { |
72 if (topic != "content-document-global-created") | 72 if (topic != "content-document-global-created") |
Thomas Greiner
2016/03/08 12:34:44
Detail: Is this check necessary given that you've
Wladimir Palant
2016/03/08 14:37:48
It's a somewhat theoretical scenario but some misg
| |
73 return; | 73 return; |
74 if (!(subject instanceof Ci.nsIDOMWindow)) | 74 if (!(subject instanceof Ci.nsIDOMWindow)) |
75 return; | 75 return; |
76 | 76 |
77 subject.addEventListener("DOMContentLoaded", handlePageLoad); | 77 subject.addEventListener("DOMContentLoaded", handlePageLoad); |
Thomas Greiner
2016/03/08 12:34:43
Detail: We usually explicitly specify the "useCapt
Wladimir Palant
2016/03/08 14:37:48
Well, we can stop doing that - it's optional ever
| |
78 } | 78 } |
79 | 79 |
80 function handlePageLoad(event) | 80 function handlePageLoad(event) |
81 { | 81 { |
82 let document = event.target; | 82 let document = event.target; |
83 if (document.documentURI.indexOf("about:neterror?") != 0 || | 83 if (document.documentURI.indexOf("about:neterror?") != 0 || |
84 document.documentURI.indexOf("e=netOffline") > 0 || | 84 document.documentURI.indexOf("e=netOffline") > 0 || |
85 document.documentURI.indexOf("e=notCached") > 0) | 85 document.documentURI.indexOf("e=notCached") > 0) |
86 { | 86 { |
87 return; | 87 return; |
(...skipping 30 matching lines...) Expand all Loading... | |
118 function parseURL(url) | 118 function parseURL(url) |
119 { | 119 { |
120 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) | 120 if (/^\s*((?:\w+:)?\/*(?:[^\/#]*@)?)([^\/:#]*)/.test(url)) |
121 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; | 121 return [RegExp.$1, RegExp.$2.toLowerCase(), RegExp.rightContext]; |
122 else | 122 else |
123 return [url, null, null]; | 123 return [url, null, null]; |
124 } | 124 } |
125 | 125 |
126 addMessageListener("URLFixer:NetErrorOverlay", receivedNetErrorOverlay); | 126 addMessageListener("URLFixer:NetErrorOverlay", receivedNetErrorOverlay); |
127 addMessageListener("URLFixer:Shutdown", shutdown); | 127 addMessageListener("URLFixer:Shutdown", shutdown); |
128 onShutdown.add(() => { | 128 onShutdown.add(() => |
129 { | |
129 removeMessageListener("URLFixer:NetErrorOverlay", receivedNetErrorOverlay); | 130 removeMessageListener("URLFixer:NetErrorOverlay", receivedNetErrorOverlay); |
130 removeMessageListener("URLFixer:Shutdown", shutdown); | 131 removeMessageListener("URLFixer:Shutdown", shutdown); |
131 }); | 132 }); |
132 sendAsyncMessage("URLFixer:GetNetErrorOverlay"); | 133 sendAsyncMessage("URLFixer:GetNetErrorOverlay"); |
133 | 134 |
134 Services.obs.addObserver(onDocumentCreated, "content-document-global-created", f alse); | 135 Services.obs.addObserver(onDocumentCreated, "content-document-global-created", f alse); |
135 onShutdown.add(() => { | 136 onShutdown.add(() => |
137 { | |
136 Services.obs.removeObserver(onDocumentCreated, "content-document-global-create d"); | 138 Services.obs.removeObserver(onDocumentCreated, "content-document-global-create d"); |
137 }); | 139 }); |
LEFT | RIGHT |