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

Side by Side Diff: chrome/content/errors.html

Issue 29331734: Issue 3357 - Get rid of chrome://adblockplus/content/errors.html (Closed)
Patch Set: Created Dec. 2, 2015, 1:15 p.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
(Empty)
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6 <title>Adblock Plus Errors</title>
7 <style type="text/css">
8 .warning, .error
9 {
10 border: 1px dashed black;
11 margin: 5px;
12 padding: 2px;
13 white-space: pre-wrap;
14 }
15
16 .error
17 {
18 background-color: #fff0f0;
19 }
20
21 .warning
22 {
23 background-color: #ffffe0;
24 }
25
26 button
27 {
28 float: right;
29 }
30 </style>
31 </head>
32 <body>
33 <button onclick="window.location.reload();">Refresh</button>
34 <button onclick="clearErrors();">Clear errors</button>
35
36 <script type="application/x-javascript;version=1.7">
37 let id = null;
38 try {
39 let {addonVersion, addonID} = require("info");
40
41 let text = "You are running Adblock Plus " + addonVersion;
42 text += ".";
43 document.write("<p>" + text + "</p>");
44
45 id = addonID.replace(/[\{\}]/g, "");
46 } catch (e) {}
47
48 // See https://bugzilla.mozilla.org/show_bug.cgi?id=664695 - starting with
49 // Gecko 19 this function returns the result, before that it wrote to a
50 // parameter.
51 let outparam = {};
52 let messages = Components.classes["@mozilla.org/consoleservice;1"]
53 .getService(Components.interfaces.nsIConsoleService)
54 .getMessageArray(outparam, {});
55 messages = messages || outparam.value || [];
56 messages = messages.filter(function(message)
57 {
58 return (message instanceof Components.interfaces.nsIScriptError &&
59 !/^https?:/i.test(message.sourceName) &&
60 (/adblock/i.test(message.errorMessage) || /adblock/i.test(message.sour ceName) ||
61 id && (message.errorMessage.indexOf(id) >= 0 || message.sourceName && message.sourceName.indexOf(id) >= 0)));
62 });
63
64 if (messages.length)
65 {
66 document.write("<p>Errors related to Adblock Plus:</p>");
67
68 for (let message of messages)
69 {
70 let type = (message.flags & Components.interfaces.nsIScriptError.warning Flag ? "warning" : "error");
71 let html = "<b>" + (type == "warning" ? "Warning:" : "Error:") + "</b><b r>";
72 html += encodeHTML(message.errorMessage) + "<br><br>";
73 if (message.sourceLine)
74 html += "Source line: " + encodeHTML(message.sourceLine) + "<br>";
75 if (message.sourceName)
76 html += "Location: " + encodeHTML(message.sourceName) + " line " + mes sage.lineNumber + "<br>";
77 html = html.replace(/(<br>)+$/, "");
78 document.write("<div class='" + type + "'>" +
79 html +
80 "</div>");
81 }
82 }
83 else
84 {
85 document.write("<p>No errors found.</p>");
86 }
87
88 function require(module)
89 {
90 let {Services} = Components.utils.import("resource://gre/modules/Services. jsm");
91 let result = {};
92 result.wrappedJSObject = result;
93 Services.obs.notifyObservers(result, "adblockplus-require", module);
94 return result.exports;
95 }
96
97 function encodeHTML(string)
98 {
99 return string.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, " &gt;");
100 }
101
102 function clearErrors()
103 {
104 Components.classes["@mozilla.org/consoleservice;1"]
105 .getService(Components.interfaces.nsIConsoleService)
106 .reset();
107 window.location.reload();
108 }
109 </script>
110 </body>
111 </html>
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