toolkit/devtools/server/tests/unit/test_objectgrips-04.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 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 var gDebuggee;
     5 var gClient;
     6 var gThreadClient;
     8 function run_test()
     9 {
    10   initTestDebuggerServer();
    11   gDebuggee = addTestGlobal("test-grips");
    12   gDebuggee.eval(function stopMe(arg1) {
    13     debugger;
    14   }.toString());
    16   gClient = new DebuggerClient(DebuggerServer.connectPipe());
    17   gClient.connect(function() {
    18     attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
    19       gThreadClient = aThreadClient;
    20       test_object_grip();
    21     });
    22   });
    23   do_test_pending();
    24 }
    26 function test_object_grip()
    27 {
    28   gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    29     let args = aPacket.frame.arguments;
    31     do_check_eq(args[0].class, "Object");
    33     let objClient = gThreadClient.pauseGrip(args[0]);
    34     objClient.getPrototypeAndProperties(function(aResponse) {
    35       do_check_eq(aResponse.ownProperties.x.configurable, true);
    36       do_check_eq(aResponse.ownProperties.x.enumerable, true);
    37       do_check_eq(aResponse.ownProperties.x.writable, true);
    38       do_check_eq(aResponse.ownProperties.x.value, 10);
    40       do_check_eq(aResponse.ownProperties.y.configurable, true);
    41       do_check_eq(aResponse.ownProperties.y.enumerable, true);
    42       do_check_eq(aResponse.ownProperties.y.writable, true);
    43       do_check_eq(aResponse.ownProperties.y.value, "kaiju");
    45       do_check_eq(aResponse.ownProperties.a.configurable, true);
    46       do_check_eq(aResponse.ownProperties.a.enumerable, true);
    47       do_check_eq(aResponse.ownProperties.a.get.type, "object");
    48       do_check_eq(aResponse.ownProperties.a.get.class, "Function");
    49       do_check_eq(aResponse.ownProperties.a.set.type, "undefined");
    51       do_check_true(aResponse.prototype != undefined);
    53       let protoClient = gThreadClient.pauseGrip(aResponse.prototype);
    54       protoClient.getOwnPropertyNames(function(aResponse) {
    55         do_check_true(aResponse.ownPropertyNames.toString != undefined);
    57         gThreadClient.resume(function() {
    58           finishClient(gClient);
    59         });
    60       });
    61     });
    63   });
    65   gDebuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
    66 }

mercurial