summaryrefslogtreecommitdiffstats
path: root/dom/console/tests/xpcshell/test_reportForServiceWorkerScope.js
blob: f96519183c00344fff8fa9911ca2515e001dba54 (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
34
35
36
37
38
39
40
41
42
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

add_task(async function () {
  let p = new Promise(resolve => {
    function consoleListener() {
      addConsoleStorageListener(this);
    }

    consoleListener.prototype = {
      observe(aSubject) {
        let obj = aSubject.wrappedJSObject;
        Assert.ok(obj.arguments[0] === "Hello world!", "Message received!");
        Assert.ok(obj.ID === "scope", "The ID is the scope");
        Assert.ok(
          obj.innerID === "ServiceWorker",
          "The innerID is ServiceWorker"
        );
        Assert.ok(obj.filename === "filename", "The filename matches");
        Assert.ok(obj.lineNumber === 42, "The lineNumber matches");
        Assert.ok(obj.columnNumber === 24, "The columnNumber matches");
        Assert.ok(obj.level === "error", "The level is correct");

        removeConsoleStorageListener(this);
        resolve();
      },
    };

    new consoleListener();
  });

  let ci = console.createInstance();
  ci.reportForServiceWorkerScope(
    "scope",
    "Hello world!",
    "filename",
    42,
    24,
    "error"
  );
  await p;
});