summaryrefslogtreecommitdiff
path: root/src/content/webglHook.js
blob: d4c064a3a7927278125cb21a070be0aa0b34c5f8 (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
{
  debug("WebGL Hook", document.URL, document.documentElement && document.documentElement.innerHTML); // DEV_ONLY
  let proto = HTMLCanvasElement.prototype;
  let getContext = proto.getContext;
  exportFunction(function(type, ...rest) {
    if (type && type.toLowerCase().includes("webgl")) {
      let request = {
        id: "noscript-webgl",
        type: "webgl",
        url: document.URL,
        documentUrl: document.URL,
        embeddingDocument: true,
      };
      seen.record({policyType: "webgl", request, allowed: false});
      try {
        let ph = PlaceHolder.create("webgl", request);
        ph.replace(this);
        PlaceHolder.listen();
      } catch (e) {
        error(e);
      }
      notifyPage();
      return {};
    }
    return getContext.call(this, type, ...rest);
  }, proto, {defineAs: "getContext"});
  document.URL;
}