summaryrefslogtreecommitdiffstats
path: root/browser/extensions/webcompat/injections/js/bug1799980-healow.com-infinite-loop-fix.js
blob: b52f1f4702075fcda8cb421af990ad36c6945a1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";

/**
 * Bug 1799980 - Healow gets stuck in an infinite loop while pages load
 *
 * This patch keeps Healow's localization scripts from getting stuck in
 * an infinite loop while their pages are loading.
 *
 * This happens because they use synchronous XMLHttpRequests to fetch a
 * JSON file with their localized text on the first call to their i18n
 * function, and then force subsequent calls to wait for it by waiting
 * in an infinite loop.
 *
 * But since they're in an infinite loop, the code after the syncXHR will
 * never be able to run, so this ultimately triggers a slow script warning.
 *
 * We can improve this by just preventing the infinite loop from happening,
 * though since they disable caching on their JSON files it means that more
 * XHRs may happen. But since those files are small, this seems like a
 * reasonable compromise until they migrate to a better i18n solution.
 *
 * See https://bugzilla.mozilla.org/show_bug.cgi?id=1799980 for details.
 */

/* globals exportFunction */

Object.defineProperty(window.wrappedJSObject, "ajaxRequestProcessing", {
  get: exportFunction(function() {
    return false;
  }, window),

  set: exportFunction(function() {}, window),
});