toolkit/devtools/server/tests/unit/test_objectgrips-04.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/server/tests/unit/test_objectgrips-04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +var gDebuggee;
     1.8 +var gClient;
     1.9 +var gThreadClient;
    1.10 +
    1.11 +function run_test()
    1.12 +{
    1.13 +  initTestDebuggerServer();
    1.14 +  gDebuggee = addTestGlobal("test-grips");
    1.15 +  gDebuggee.eval(function stopMe(arg1) {
    1.16 +    debugger;
    1.17 +  }.toString());
    1.18 +
    1.19 +  gClient = new DebuggerClient(DebuggerServer.connectPipe());
    1.20 +  gClient.connect(function() {
    1.21 +    attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
    1.22 +      gThreadClient = aThreadClient;
    1.23 +      test_object_grip();
    1.24 +    });
    1.25 +  });
    1.26 +  do_test_pending();
    1.27 +}
    1.28 +
    1.29 +function test_object_grip()
    1.30 +{
    1.31 +  gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    1.32 +    let args = aPacket.frame.arguments;
    1.33 +
    1.34 +    do_check_eq(args[0].class, "Object");
    1.35 +
    1.36 +    let objClient = gThreadClient.pauseGrip(args[0]);
    1.37 +    objClient.getPrototypeAndProperties(function(aResponse) {
    1.38 +      do_check_eq(aResponse.ownProperties.x.configurable, true);
    1.39 +      do_check_eq(aResponse.ownProperties.x.enumerable, true);
    1.40 +      do_check_eq(aResponse.ownProperties.x.writable, true);
    1.41 +      do_check_eq(aResponse.ownProperties.x.value, 10);
    1.42 +
    1.43 +      do_check_eq(aResponse.ownProperties.y.configurable, true);
    1.44 +      do_check_eq(aResponse.ownProperties.y.enumerable, true);
    1.45 +      do_check_eq(aResponse.ownProperties.y.writable, true);
    1.46 +      do_check_eq(aResponse.ownProperties.y.value, "kaiju");
    1.47 +
    1.48 +      do_check_eq(aResponse.ownProperties.a.configurable, true);
    1.49 +      do_check_eq(aResponse.ownProperties.a.enumerable, true);
    1.50 +      do_check_eq(aResponse.ownProperties.a.get.type, "object");
    1.51 +      do_check_eq(aResponse.ownProperties.a.get.class, "Function");
    1.52 +      do_check_eq(aResponse.ownProperties.a.set.type, "undefined");
    1.53 +
    1.54 +      do_check_true(aResponse.prototype != undefined);
    1.55 +
    1.56 +      let protoClient = gThreadClient.pauseGrip(aResponse.prototype);
    1.57 +      protoClient.getOwnPropertyNames(function(aResponse) {
    1.58 +        do_check_true(aResponse.ownPropertyNames.toString != undefined);
    1.59 +
    1.60 +        gThreadClient.resume(function() {
    1.61 +          finishClient(gClient);
    1.62 +        });
    1.63 +      });
    1.64 +    });
    1.65 +
    1.66 +  });
    1.67 +
    1.68 +  gDebuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
    1.69 +}
    1.70 +

mercurial