How to find a JS function declaration in browser sources?

后端 未结 1 517
刺人心
刺人心 2021-01-23 08:29

How do I find a JS function declaration in the sources of FF ?

First I wanted to find declaration of function \"copy\". I opened console, typed and executed \'copy.toSou

相关标签:
1条回答
  • 2021-01-23 08:45

    The source of copy (assuming you mean "copy to clipboard") is in ./toolkit/devtools/webconsole/utils.js. It is small, so here it is:

    WebConsoleCommands._registerOriginal("copy", function JSTH_copy(aOwner, aValue)
    {
      let payload;
      try {
        if (aValue instanceof Ci.nsIDOMElement) {
          payload = aValue.outerHTML;
        } else if (typeof aValue == "string") {
          payload = aValue;
        } else {
          payload = JSON.stringify(aValue, null, "  ");
        }
      } catch (ex) {
        payload = "/* " + ex  + " */";
      }
      aOwner.helperResult = {
        type: "copyValueToClipboard",
        value: payload,
      };
    });
    

    The console.*functions get defined in ./dom/base/Console.cpp

    0 讨论(0)
提交回复
热议问题