browser/devtools/webconsole/test/browser_webconsole_property_provider.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* vim:set ts=2 sw=2 sts=2 et: */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 // Tests the property provider, which is part of the code completion
     7 // infrastructure.
     9 const TEST_URI = "data:text/html;charset=utf8,<p>test the JS property provider";
    11 function test() {
    12   addTab(TEST_URI);
    13   browser.addEventListener("load", testPropertyProvider, true);
    14 }
    16 function testPropertyProvider() {
    17   browser.removeEventListener("load", testPropertyProvider, true);
    18   let tools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
    19   let JSPropertyProvider = tools.require("devtools/toolkit/webconsole/utils").JSPropertyProvider;
    21   let tmp = Cu.import("resource://gre/modules/jsdebugger.jsm", {});
    22   tmp.addDebuggerToGlobal(tmp);
    23   let dbg = new tmp.Debugger;
    24   let dbgWindow = dbg.makeGlobalObjectReference(content);
    26   let completion = JSPropertyProvider(dbgWindow, null, "thisIsNotDefined");
    27   is (completion.matches.length, 0, "no match for 'thisIsNotDefined");
    29   // This is a case the PropertyProvider can't handle. Should return null.
    30   completion = JSPropertyProvider(dbgWindow, null, "window[1].acb");
    31   is (completion, null, "no match for 'window[1].acb");
    33   // A very advanced completion case.
    34   var strComplete =
    35     'function a() { }document;document.getElementById(window.locatio';
    36   completion = JSPropertyProvider(dbgWindow, null, strComplete);
    37   ok(completion.matches.length == 2, "two matches found");
    38   ok(completion.matchProp == "locatio", "matching part is 'test'");
    39   var matches = completion.matches;
    40   matches.sort();
    41   ok(matches[0] == "location", "the first match is 'location'");
    42   ok(matches[1] == "locationbar", "the second match is 'locationbar'");
    44   finishTest();
    45 }

mercurial