toolkit/devtools/webconsole/test/test_bug819670_getter_throws.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/webconsole/test/test_bug819670_getter_throws.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html lang="en">
     1.6 +<head>
     1.7 +  <meta charset="utf8">
     1.8 +  <title>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</title>
     1.9 +  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.10 +  <script type="text/javascript;version=1.8" src="common.js"></script>
    1.11 +  <!-- Any copyright is dedicated to the Public Domain.
    1.12 +     - http://creativecommons.org/publicdomain/zero/1.0/ -->
    1.13 +</head>
    1.14 +<body>
    1.15 +<p>Test for Bug 819670 - Web console object inspection does not handle native getters throwing very well</p>
    1.16 +
    1.17 +<script class="testbody" type="text/javascript;version=1.8">
    1.18 +SimpleTest.waitForExplicitFinish();
    1.19 +
    1.20 +function startTest()
    1.21 +{
    1.22 +  removeEventListener("load", startTest);
    1.23 +  attachConsole([], onAttach, true);
    1.24 +}
    1.25 +
    1.26 +function onAttach(aState, aResponse)
    1.27 +{
    1.28 +  onEvaluate = onEvaluate.bind(null, aState);
    1.29 +  aState.client.evaluateJS("document.__proto__", onEvaluate);
    1.30 +}
    1.31 +
    1.32 +function onEvaluate(aState, aResponse)
    1.33 +{
    1.34 +  checkObject(aResponse, {
    1.35 +    from: aState.actor,
    1.36 +    input: "document.__proto__",
    1.37 +    result: {
    1.38 +      type: "object",
    1.39 +      actor: /[a-z]/,
    1.40 +    },
    1.41 +  });
    1.42 +
    1.43 +  ok(!aResponse.exception, "no eval exception");
    1.44 +  ok(!aResponse.helperResult, "no helper result");
    1.45 +
    1.46 +  onInspect = onInspect.bind(null, aState);
    1.47 +  let client = new ObjectClient(aState.dbgClient, aResponse.result);
    1.48 +  client.getPrototypeAndProperties(onInspect);
    1.49 +}
    1.50 +
    1.51 +function onInspect(aState, aResponse)
    1.52 +{
    1.53 +  ok(!aResponse.error, "no response error");
    1.54 +
    1.55 +  let expectedProps = {
    1.56 +    "addBroadcastListenerFor": { value: { type: "object" } },
    1.57 +    "commandDispatcher": { get: { type: "object" } },
    1.58 +    "getBoxObjectFor": { value: { type: "object" } },
    1.59 +    "getElementsByAttribute": { value: { type: "object" } },
    1.60 +  };
    1.61 +
    1.62 +  let props = aResponse.ownProperties;
    1.63 +  ok(props, "response properties available");
    1.64 +
    1.65 +  if (props) {
    1.66 +    ok(Object.keys(props).length > Object.keys(expectedProps).length,
    1.67 +       "number of enumerable properties");
    1.68 +    checkObject(props, expectedProps);
    1.69 +  }
    1.70 +
    1.71 +  closeDebugger(aState, function() {
    1.72 +    SimpleTest.finish();
    1.73 +  });
    1.74 +}
    1.75 +
    1.76 +addEventListener("load", startTest);
    1.77 +</script>
    1.78 +</body>
    1.79 +</html>

mercurial