toolkit/devtools/webconsole/test/test_jsterm_cd_iframe.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/webconsole/test/test_jsterm_cd_iframe.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,154 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html lang="en">
     1.6 +<head>
     1.7 +  <meta charset="utf8">
     1.8 +  <title>Test for the cd() function</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 the cd() function</p>
    1.16 +
    1.17 +<script class="testbody" type="text/javascript;version=1.8">
    1.18 +SimpleTest.waitForExplicitFinish();
    1.19 +
    1.20 +let gState;
    1.21 +
    1.22 +function startTest()
    1.23 +{
    1.24 +  removeEventListener("load", startTest);
    1.25 +
    1.26 +  attachConsole([], onAttach, true);
    1.27 +}
    1.28 +
    1.29 +function onAttach(aState, aResponse)
    1.30 +{
    1.31 +  top.foobarObject = Object.create(null);
    1.32 +  top.foobarObject.bug609872 = "parent";
    1.33 +
    1.34 +  window.foobarObject = Object.create(null);
    1.35 +  window.foobarObject.bug609872 = "child";
    1.36 +
    1.37 +  gState = aState;
    1.38 +
    1.39 +  let tests = [doCheckParent, doCdIframe, doCheckIframe, doCdParent,
    1.40 +      doCheckParent2];
    1.41 +  runTests(tests, testEnd);
    1.42 +}
    1.43 +
    1.44 +function doCheckParent()
    1.45 +{
    1.46 +  info("check parent window");
    1.47 +  gState.client.evaluateJS("window.foobarObject.bug609872",
    1.48 +      onFooObjectFromParent);
    1.49 +}
    1.50 +
    1.51 +function onFooObjectFromParent(aResponse)
    1.52 +{
    1.53 +  checkObject(aResponse, {
    1.54 +    from: gState.actor,
    1.55 +    input: "window.foobarObject.bug609872",
    1.56 +    result: "parent",
    1.57 +  });
    1.58 +
    1.59 +  ok(!aResponse.exception, "no eval exception");
    1.60 +  ok(!aResponse.helperResult, "no helper result");
    1.61 +
    1.62 +  nextTest();
    1.63 +}
    1.64 +
    1.65 +function doCdIframe()
    1.66 +{
    1.67 +  info("test cd('iframe')");
    1.68 +  gState.client.evaluateJS("cd('iframe')", onCdIframe);
    1.69 +}
    1.70 +
    1.71 +function onCdIframe(aResponse)
    1.72 +{
    1.73 +  checkObject(aResponse, {
    1.74 +    from: gState.actor,
    1.75 +    input: "cd('iframe')",
    1.76 +    result: { type: "undefined" },
    1.77 +    helperResult: { type: "cd" },
    1.78 +  });
    1.79 +
    1.80 +  ok(!aResponse.exception, "no eval exception");
    1.81 +
    1.82 +  nextTest();
    1.83 +}
    1.84 +
    1.85 +function doCheckIframe()
    1.86 +{
    1.87 +  info("check foobarObject from the iframe");
    1.88 +  gState.client.evaluateJS("window.foobarObject.bug609872",
    1.89 +                           onFooObjectFromIframe);
    1.90 +}
    1.91 +
    1.92 +function onFooObjectFromIframe(aResponse)
    1.93 +{
    1.94 +  checkObject(aResponse, {
    1.95 +    from: gState.actor,
    1.96 +    input: "window.foobarObject.bug609872",
    1.97 +    result: "child",
    1.98 +  });
    1.99 +
   1.100 +  ok(!aResponse.exception, "no js eval exception");
   1.101 +  ok(!aResponse.helperResult, "no helper result");
   1.102 +
   1.103 +  nextTest();
   1.104 +}
   1.105 +
   1.106 +function doCdParent()
   1.107 +{
   1.108 +  info("test cd() back to parent");
   1.109 +  gState.client.evaluateJS("cd()", onCdParent);
   1.110 +}
   1.111 +
   1.112 +function onCdParent(aResponse)
   1.113 +{
   1.114 +  checkObject(aResponse, {
   1.115 +    from: gState.actor,
   1.116 +    input: "cd()",
   1.117 +    result: { type: "undefined" },
   1.118 +    helperResult: { type: "cd" },
   1.119 +  });
   1.120 +
   1.121 +  ok(!aResponse.exception, "no eval exception");
   1.122 +
   1.123 +  nextTest();
   1.124 +}
   1.125 +
   1.126 +function doCheckParent2()
   1.127 +{
   1.128 +  gState.client.evaluateJS("window.foobarObject.bug609872",
   1.129 +                           onFooObjectFromParent2);
   1.130 +}
   1.131 +
   1.132 +function onFooObjectFromParent2(aResponse)
   1.133 +{
   1.134 +  checkObject(aResponse, {
   1.135 +    from: gState.actor,
   1.136 +    input: "window.foobarObject.bug609872",
   1.137 +    result: "parent",
   1.138 +  });
   1.139 +
   1.140 +  ok(!aResponse.exception, "no eval exception");
   1.141 +  ok(!aResponse.helperResult, "no helper result");
   1.142 +
   1.143 +  nextTest();
   1.144 +}
   1.145 +
   1.146 +function testEnd()
   1.147 +{
   1.148 +  closeDebugger(gState, function() {
   1.149 +    gState = null;
   1.150 +    SimpleTest.finish();
   1.151 +  });
   1.152 +}
   1.153 +
   1.154 +addEventListener("load", startTest);
   1.155 +</script>
   1.156 +</body>
   1.157 +</html>

mercurial