tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_function_names.js (1383B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 function callback() {}
      5 
      6 let sandbox = Cu.Sandbox(this);
      7 let callbackWrapped = Cu.evalInSandbox("(function wrapped() {})", sandbox);
      8 
      9 function run_test() {
     10  let functions = [
     11    [{ notify: callback }, "callback[test_function_names.js]:JS"],
     12    [{ notify: { notify: callback } }, "callback[test_function_names.js]:JS"],
     13    [callback, "callback[test_function_names.js]:JS"],
     14    [function() {}, "run_test/functions<[test_function_names.js]:JS"],
     15    [function foobar() {}, "foobar[test_function_names.js]:JS"],
     16    [function Δ() {}, "Δ[test_function_names.js]:JS"],
     17    [{ notify1: callback, notify2: callback }, "nonfunction:JS"],
     18    [{ notify: 10 }, "nonfunction:JS"],
     19    [{}, "nonfunction:JS"],
     20    [{ notify: callbackWrapped }, "wrapped[test_function_names.js]:JS"],
     21  ];
     22 
     23  // Use the observer service so we can get double-wrapped functions.
     24  var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
     25 
     26  function observer(subject, topic, data)
     27  {
     28    let named = subject.QueryInterface(Ci.nsINamed);
     29    Assert.equal(named.name, data);
     30    dump(`name: ${named.name}\n`);
     31  }
     32  obs.addObserver(observer, "test-obs-fun", false);
     33 
     34  for (let [f, requiredName] of functions) {
     35    obs.notifyObservers(f, "test-obs-fun", requiredName);
     36  }
     37 }