|
58 | 58 | t0,
|
59 | 59 | pad = 25,
|
60 | 60 | isTimeOut = false,
|
61 |
| - isThrowError = false |
| 61 | + isThrowError = false, |
| 62 | + useNew |
62 | 63 |
|
63 | 64 | let notNormal = sb +" not normal"+ sc +" [now you <b><u>really</u></b> stand out]",
|
64 | 65 | goodResult = sg +"result: "+ sc,
|
|
69 | 70 | 2: goodResult +"update your browser" +"<br><br><div class='indent faint'>this PoC requires FF89+ to be fully effective</div>",
|
70 | 71 | 3: badResult +"timed out:"+ notNormal,
|
71 | 72 | 4: badResult,
|
72 |
| - 4: goodResult, |
| 73 | + 5: goodResult, |
| 74 | + 6: badResult +"mixed chrome:// test results", |
| 75 | + 7: "pending", |
73 | 76 | }
|
74 | 77 |
|
75 |
| -const get_old_OS = () => new Promise(resolve => { |
| 78 | +const get_thisOS = () => new Promise(resolve => { |
76 | 79 | // FF89-123
|
77 | 80 | // 1280128: FF51+ win/mac | 1701257: FF89+ linux, therefore undefined = android
|
78 | 81 | function exit() {
|
|
81 | 84 | }
|
82 | 85 | setTimeout(() => resolve("timed out"), 100)
|
83 | 86 |
|
| 87 | + if (useNew) {thisOS = 0} // count instead |
84 | 88 | if (!isTimeOut) {
|
85 | 89 | // FF121+: 1855861
|
| 90 | + // FF124+: 1874232 |
| 91 | + // new: chrome://browser/content/extension-popup-panel.css |
| 92 | + // fallback: chrome://browser/content/extension.css |
| 93 | + // both these are desktop only |
| 94 | + |
86 | 95 | const get_event = (css, item) => new Promise(resolve => {
|
87 | 96 | css.onload = function() {
|
| 97 | + if (useNew) { |
| 98 | + //desktop vs android |
| 99 | + thisOS++ |
| 100 | + } else { |
88 | 101 | thisOS = item == "win" ? "windows" : item
|
89 |
| - count++ |
90 |
| - document.head.removeChild(css) |
91 |
| - aDebug.push(s3 + (item +": ").padStart(pad) + sc + green_tick +" detected") |
92 |
| - if (count == 3) {exit()} |
93 |
| - //exit(true) // comment out: test all three for debugging |
94 |
| - return resolve() |
95 | 102 | }
|
96 |
| - css.onerror = function() { |
97 | 103 | count++
|
98 | 104 | document.head.removeChild(css)
|
99 |
| - aDebug.push(s3 + (item +": ").padStart(pad) + sc + red_cross +" not detected") |
100 |
| - if (count == 3) {exit()} |
| 105 | + aDebug.push(s3 + (item +": ").padStart(pad) + sc + green_tick +" detected") |
| 106 | + if (count == maxCount) {exit()} |
| 107 | + //exit(true) // comment out: test all three for debugging |
101 | 108 | return resolve()
|
102 | 109 | }
|
103 |
| - }) |
104 |
| - |
105 |
| - let count = 0 |
106 |
| - try { |
107 |
| - let path = "chrome://browser/content/extension-", suffix = "-panel.css" |
108 |
| - aDebug.push(s13 + "chrome:// test: ".padStart(pad) + sc +"browser/content/extension-*"+ suffix) |
109 |
| - if (isThrowError) {foo++} |
110 |
| - let list = ["win", "mac","linux"] |
111 |
| - list.forEach(function(item) { |
112 |
| - let css = document.createElement("link") |
113 |
| - css.type = "text/css" |
114 |
| - css.rel = "stylesheet" |
115 |
| - css.href = path + item + suffix |
116 |
| - document.head.appendChild(css) |
117 |
| - get_event(css, item) |
118 |
| - }) |
119 |
| - } catch(e) { |
120 |
| - oMessages[4] = badResult + "error:" + notNormal + "<br><br><div class='indent faint'>"+ e +"</div>" |
121 |
| - aDebug.push(sb + ("error: ").padStart(pad) + sc + e.name) |
122 |
| - return resolve("error") |
123 |
| - } |
124 |
| - } |
125 |
| -}) |
126 |
| - |
127 |
| -const get_desktop = () => new Promise(resolve => { |
128 |
| - function exit() { |
129 |
| - return resolve() |
130 |
| - } |
131 |
| - setTimeout(() => resolve("timed out"), 100) |
132 |
| - |
133 |
| - if (!isTimeOut) { |
134 |
| - // FF124+: 1874232 |
135 |
| - // added: chrome://browser/content/extension-popup-panel.css |
136 |
| - // also: chrome://browser/content/extension.css is apparently desktop only? |
137 |
| - |
138 |
| - const get_event = (css, item) => new Promise(resolve => { |
139 |
| - css.onload = function() { |
140 |
| - count++ |
141 |
| - document.head.removeChild(css) |
142 |
| - aDebug.push(s3 + (item +": ").padStart(pad) + sc + green_tick +" detected") |
143 |
| - if (count == 2) {exit()} |
144 |
| - return resolve() |
145 |
| - } |
146 | 110 | css.onerror = function() {
|
147 | 111 | count++
|
148 | 112 | document.head.removeChild(css)
|
149 | 113 | aDebug.push(s3 + (item +": ").padStart(pad) + sc + red_cross +" not detected")
|
150 |
| - if (count == 2) {exit()} |
| 114 | + if (count == maxCount) {exit()} |
151 | 115 | return resolve()
|
152 | 116 | }
|
153 | 117 | })
|
154 | 118 |
|
155 |
| - let count = 0 |
| 119 | + let count = 0, maxCount |
156 | 120 | try {
|
| 121 | + let path = "chrome://browser/content/extension-", suffix = "-panel.css" |
| 122 | + let list = ["win", "mac","linux"] |
| 123 | + if (useNew) { |
| 124 | + list = ['extension-popup-panel','extension'] |
| 125 | + path = "chrome://browser/content/", suffix = ".css" |
| 126 | + aDebug.push(s13 + "124+ chrome:// test: ".padStart(pad) + sc + path +"*.css") |
| 127 | + } else { |
| 128 | + aDebug.push(s13 + "89-123 chrome:// test: ".padStart(pad) + sc +"browser/content/extension-*"+ suffix) |
| 129 | + } |
157 | 130 | if (isThrowError) {foo++}
|
158 |
| - let path = "chrome://browser/content/", suffix = ".css" |
159 |
| - aDebug.push(s13 + "chrome:// test: ".padStart(pad) + sc + path +"*.css") |
160 |
| - let list = ['extension-popup-panel','extension'] |
| 131 | + maxCount = list.length |
161 | 132 | list.forEach(function(item) {
|
162 | 133 | let css = document.createElement("link")
|
163 | 134 | css.type = "text/css"
|
|
172 | 143 | return resolve("error")
|
173 | 144 | }
|
174 | 145 | }
|
175 |
| - |
176 | 146 | })
|
177 | 147 |
|
178 | 148 | function run() {
|
179 | 149 | t0 = performance.now()
|
180 | 150 | dom.os.innerHTML = ""
|
181 | 151 | dom.debug.innerHTML = ""
|
| 152 | + let notation = "" |
182 | 153 |
|
183 | 154 | function exit(type) {
|
184 | 155 | dom.perf = Math.round((performance.now() - t0)) + " ms"
|
185 | 156 | dom.debug.innerHTML = aDebug.join("<br>")
|
186 |
| - if (type < 6) { |
187 |
| - dom.os.innerHTML = oMessages[type] |
188 |
| - } else { |
189 |
| - dom.os.innerHTML = "pending" |
190 |
| - } |
| 157 | + if (type < 8) {dom.os.innerHTML = oMessages[type]} else {dom.os.innerHTML = "pending"} |
191 | 158 | }
|
192 |
| - |
193 | 159 | if (!isFF) {
|
194 | 160 | exit(1)
|
195 | 161 | } else if (isVer < 89) {
|
196 | 162 | exit(2)
|
197 |
| - } else if (isVer < 124) { |
| 163 | + } else { |
198 | 164 | Promise.all([
|
199 |
| - get_old_OS() |
| 165 | + get_thisOS() |
200 | 166 | ]).then(function(res){
|
201 | 167 | let result = res[0]
|
202 | 168 | if (result == "timed out") {
|
|
205 | 171 | } else if (result == "error") {
|
206 | 172 | exit(4)
|
207 | 173 | } else {
|
208 |
| - oMessages[5] = goodResult + thisOS |
209 |
| - exit(5) |
210 |
| - } |
211 |
| - }) |
212 |
| - } else { |
213 |
| - Promise.all([ |
214 |
| - get_desktop() |
215 |
| - ]).then(function(res){ |
216 |
| - let result = res[0] |
217 |
| - if (result == "timed out") { |
218 |
| - aDebug.push(sb + ("timed out: ").padStart(pad) + sc) |
| 174 | + if (useNew) { |
| 175 | + // logis: must be 0 or 2, not 1, so I can pickup on changes |
| 176 | + if (thisOS == 0) { |
| 177 | + thisOS = "android" |
| 178 | + notation = green_tick +" none detected" |
| 179 | + } else if (thisOS == 2) { |
| 180 | + thisOS = "desktop" |
| 181 | + notation = green_tick +" both detected" |
| 182 | + } else { |
| 183 | + notation = red_cross +" mixed results" |
| 184 | + thisOS = undefined |
| 185 | + } |
| 186 | + aDebug.push(s13 + "desktop test: ".padStart(pad) + sc + notation) |
| 187 | + } |
| 188 | + // thisOS s/be (no errors or timeouts) |
| 189 | + // old: android, linux, mac, windows |
| 190 | + // new: android or desktop or undefined |
| 191 | + if (thisOS == undefined) { |
| 192 | + exit(6) // something changed upstream: address it |
| 193 | + } else if (thisOS !== "desktop") { |
| 194 | + oMessages[5] = goodResult + thisOS |
| 195 | + exit(5) // bingo! |
| 196 | + } else { |
| 197 | + oMessages[7] = "pending: "+ thisOS |
| 198 | + // desktop needws more digging |
| 199 | + exit(7) |
| 200 | + } |
219 | 201 | }
|
220 |
| - exit() |
221 |
| - |
222 | 202 | })
|
223 | 203 | }
|
224 | 204 | }
|
|
234 | 214 | ]).then(function(){
|
235 | 215 | aDebug.push(s13 + "gecko test: ".padStart(pad) + sc + isFF)
|
236 | 216 | if (isFF) {
|
| 217 | + useNew = isVer > 123 |
237 | 218 | let isVerOpen = (isVer == isVerMax +"")
|
238 | 219 | aDebug.push(s13 + "version test: ".padStart(pad) + sc + isVer + (isVerOpen ? "+" : (isVer == 52 ? " or lower" : "")))
|
239 | 220 | }
|
|
0 commit comments