summaryrefslogtreecommitdiffstats
path: root/dom/plugins/test/mochitest/test_npruntime_identifiers.html
blob: a19a59be52e6a5ecafdb320fb20afd52689f65bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<html>
<head>
  <title>NPN_Invoke Tests</title>
  <script type="text/javascript" 
          src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="plugin-utils.js"></script>
  <link rel="stylesheet" type="text/css" 
        href="/tests/SimpleTest/test.css" />
</head>
<body>
  <p id="display"></p>

  <script class="testbody" type="application/javascript">
  ////
  // This test exercises NP identifiers by querying the reflector to make sure
  // that identifiers are translated to values correctly.
  
  SimpleTest.waitForExplicitFinish();
  setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);

  var testsRun = 0;

  function doTest() {
    SpecialPowers.gc();

    var reflector = document.getElementById("subframe").contentDocument.getElementById("plugin1").getReflector();

    var i, prop, randomnumber;

    for (i = 0; i < 20; ++i) {
      randomnumber=Math.floor(Math.random()*1001);
      prop = "prop" + randomnumber;
      is(reflector[prop], prop, "Property " + prop);
    }

    for (i = -10; i < 0; ++i) {
      is(reflector[i], String(i), "Property " + i);
      prop = "prop" + i;
      is(reflector[prop], prop, "Property " + prop);
    }

    for (i = 0; i < 10; ++i) {
      is(reflector[i], i, "Property " + i);
      prop = "prop" + i;
      is(reflector[prop], prop, "Property " + prop);
    }

    is(reflector.a, 'a', "Property .a");
    is(reflector['a'], 'a', "Property ['a']");
    reflector = null;

    SpecialPowers.gc();

    ++testsRun;
    if (testsRun == 3) {
      SimpleTest.finish();
    }
    else {
      document.getElementById('subframe').contentWindow.location.reload(true);
    }
  }
  </script>

  <iframe id="subframe" src="npruntime_identifiers_subpage.html" onload="doTest()"></iframe>

</body>
</html>