| ... |
... |
@@ -8,7 +8,6 @@ const MINIMUM_DESCRIPTION_LENGTH = 10; |
|
8
|
8
|
const lazy = {};
|
|
9
|
9
|
|
|
10
|
10
|
ChromeUtils.defineESModuleGetters(lazy, {
|
|
11
|
|
- ClientEnvironment: "resource://normandy/lib/ClientEnvironment.sys.mjs",
|
|
12
|
11
|
SafeBrowsing: "resource://gre/modules/SafeBrowsing.sys.mjs",
|
|
13
|
12
|
});
|
|
14
|
13
|
|
| ... |
... |
@@ -18,7 +17,6 @@ export class ViewState { |
|
18
|
17
|
#detailsView;
|
|
19
|
18
|
#previewView;
|
|
20
|
19
|
#reportSentView;
|
|
21
|
|
- #reasonOptions;
|
|
22
|
20
|
|
|
23
|
21
|
#reportURL;
|
|
24
|
22
|
currentTabURL;
|
| ... |
... |
@@ -43,10 +41,6 @@ export class ViewState { |
|
43
|
41
|
"report-broken-site-popup-reportSentView"
|
|
44
|
42
|
);
|
|
45
|
43
|
ViewState.#cache.set(doc, this);
|
|
46
|
|
-
|
|
47
|
|
- this.#reasonOptions = Array.from(
|
|
48
|
|
- this.#mainView.querySelectorAll(".reason-button")
|
|
49
|
|
- );
|
|
50
|
44
|
}
|
|
51
|
45
|
|
|
52
|
46
|
static #cache = new WeakMap();
|
| ... |
... |
@@ -289,46 +283,6 @@ export class ViewState { |
|
289
|
283
|
);
|
|
290
|
284
|
}
|
|
291
|
285
|
|
|
292
|
|
- randomizeReasonsOrdering() {
|
|
293
|
|
- // As with QuickActionsLoaderDefault, we use the Normandy
|
|
294
|
|
- // randomizationId as our PRNG seed to ensure that the same
|
|
295
|
|
- // user should always get the same sequence.
|
|
296
|
|
- const seed = [...lazy.ClientEnvironment.randomizationId]
|
|
297
|
|
- .map(x => x.charCodeAt(0))
|
|
298
|
|
- .reduce((sum, a) => sum + a, 0);
|
|
299
|
|
-
|
|
300
|
|
- const items = [...this.#reasonOptions];
|
|
301
|
|
- this.#shuffleArray(items, seed);
|
|
302
|
|
- items[0].parentNode.append(...items);
|
|
303
|
|
- }
|
|
304
|
|
-
|
|
305
|
|
- #shuffleArray(array, seed) {
|
|
306
|
|
- // We use SplitMix as it is reputed to have a strong distribution of values.
|
|
307
|
|
- const prng = this.#getSplitMix32PRNG(seed);
|
|
308
|
|
- for (let i = array.length - 1; i > 0; i--) {
|
|
309
|
|
- const j = Math.floor(prng() * (i + 1));
|
|
310
|
|
- [array[i], array[j]] = [array[j], array[i]];
|
|
311
|
|
- }
|
|
312
|
|
- }
|
|
313
|
|
-
|
|
314
|
|
- // SplitMix32 is a splittable pseudorandom number generator (PRNG).
|
|
315
|
|
- // License: MIT (https://github.com/attilabuti/SimplexNoise)
|
|
316
|
|
- #getSplitMix32PRNG(a) {
|
|
317
|
|
- return () => {
|
|
318
|
|
- a |= 0;
|
|
319
|
|
- a = (a + 0x9e3779b9) | 0;
|
|
320
|
|
- var t = a ^ (a >>> 16);
|
|
321
|
|
- t = Math.imul(t, 0x21f0aaad);
|
|
322
|
|
- t = t ^ (t >>> 15);
|
|
323
|
|
- t = Math.imul(t, 0x735a2d97);
|
|
324
|
|
- return ((t = t ^ (t >>> 15)) >>> 0) / 4294967296;
|
|
325
|
|
- };
|
|
326
|
|
- }
|
|
327
|
|
-
|
|
328
|
|
- restoreReasonsOrdering() {
|
|
329
|
|
- this.#reasonOptions[0].parentNode.append(...this.#reasonOptions);
|
|
330
|
|
- }
|
|
331
|
|
-
|
|
332
|
286
|
reset() {
|
|
333
|
287
|
this.currentTabWebcompatDetailsPromise = undefined;
|
|
334
|
288
|
this.lastBlurredURLInputSelection = undefined;
|
| ... |
... |
@@ -445,8 +399,6 @@ export var ReportBrokenSite = new (class ReportBrokenSite { |
|
445
|
399
|
|
|
446
|
400
|
static SCREENSHOTS_ENABLED_PREF =
|
|
447
|
401
|
"ui.new-webcompat-reporter.screenshots.enabled";
|
|
448
|
|
- static REASON_RANDOMIZED_PREF =
|
|
449
|
|
- "ui.new-webcompat-reporter.reason-dropdown.randomized";
|
|
450
|
402
|
static SEND_MORE_INFO_PREF = "ui.new-webcompat-reporter.send-more-info-link";
|
|
451
|
403
|
static NEW_REPORT_ENDPOINT_PREF =
|
|
452
|
404
|
"ui.new-webcompat-reporter.new-report-endpoint";
|
| ... |
... |
@@ -490,8 +442,6 @@ export var ReportBrokenSite = new (class ReportBrokenSite { |
|
490
|
442
|
}
|
|
491
|
443
|
|
|
492
|
444
|
#OBSERVED_PREFS = {
|
|
493
|
|
- [ReportBrokenSite.REASON_RANDOMIZED_PREF]:
|
|
494
|
|
- "onReasonRandomizationPrefChanged",
|
|
495
|
445
|
[ReportBrokenSite.SCREENSHOTS_ENABLED_PREF]: "onScreenshotsPrefChanged",
|
|
496
|
446
|
[ReportBrokenSite.SEND_MORE_INFO_PREF]: "onSendMoreInfoPrefChanged",
|
|
497
|
447
|
};
|
| ... |
... |
@@ -532,14 +482,6 @@ export var ReportBrokenSite = new (class ReportBrokenSite { |
|
532
|
482
|
}
|
|
533
|
483
|
}
|
|
534
|
484
|
|
|
535
|
|
- onReasonRandomizationPrefChanged(prefValue, state) {
|
|
536
|
|
- if (prefValue) {
|
|
537
|
|
- state.randomizeReasonsOrdering();
|
|
538
|
|
- } else {
|
|
539
|
|
- state.restoreReasonsOrdering();
|
|
540
|
|
- }
|
|
541
|
|
- }
|
|
542
|
|
-
|
|
543
|
485
|
onScreenshotsPrefChanged(prefValue, state) {
|
|
544
|
486
|
state.screenshotsDisabled = !prefValue;
|
|
545
|
487
|
}
|