harmony 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.gitignore +5 -0
  2. data/LICENSE +19 -0
  3. data/Manifest +117 -0
  4. data/README.md +155 -0
  5. data/Rakefile +39 -0
  6. data/docs.watchr +25 -0
  7. data/harmony.gemspec +18 -0
  8. data/lib/harmony.rb +5 -0
  9. data/lib/harmony/page.rb +123 -0
  10. data/specs.watchr +36 -0
  11. data/test/harmony_test.rb +8 -0
  12. data/test/page_test.rb +73 -0
  13. data/test/test_helper.rb +13 -0
  14. data/vendor/README +1 -0
  15. data/vendor/envjs/README +36 -0
  16. data/vendor/envjs/bin/envjsrb +255 -0
  17. data/vendor/envjs/bin/jquery-1.2.6-test.js +33 -0
  18. data/vendor/envjs/bin/jquery-1.3.1-test.js +33 -0
  19. data/vendor/envjs/bin/jquery-1.3.2-test.js +106 -0
  20. data/vendor/envjs/bin/prototype-1.6.0.3-test.js +82 -0
  21. data/vendor/envjs/bin/prototype_1.6.0.3_tmpl.txt +27 -0
  22. data/vendor/envjs/bin/test-jquery.sh +58 -0
  23. data/vendor/envjs/bin/test-prototype.sh +54 -0
  24. data/vendor/envjs/bin/tidy +0 -0
  25. data/vendor/envjs/lib/envjs.rb +23 -0
  26. data/vendor/envjs/lib/envjs/env.js +21665 -0
  27. data/vendor/envjs/lib/envjs/net.rb +3 -0
  28. data/vendor/envjs/lib/envjs/net/cgi.rb +94 -0
  29. data/vendor/envjs/lib/envjs/net/file.rb +75 -0
  30. data/vendor/envjs/lib/envjs/options.rb +11 -0
  31. data/vendor/envjs/lib/envjs/runtime.rb +351 -0
  32. data/vendor/envjs/lib/envjs/tempfile.rb +24 -0
  33. data/vendor/envjs/test/base64.js +80 -0
  34. data/vendor/envjs/test/call-load-test.js +15 -0
  35. data/vendor/envjs/test/data.js +45 -0
  36. data/vendor/envjs/test/debug.js +53 -0
  37. data/vendor/envjs/test/firebug/errorIcon.png +0 -0
  38. data/vendor/envjs/test/firebug/firebug.css +209 -0
  39. data/vendor/envjs/test/firebug/firebug.html +23 -0
  40. data/vendor/envjs/test/firebug/firebug.js +672 -0
  41. data/vendor/envjs/test/firebug/firebugx.js +10 -0
  42. data/vendor/envjs/test/firebug/infoIcon.png +0 -0
  43. data/vendor/envjs/test/firebug/warningIcon.png +0 -0
  44. data/vendor/envjs/test/fixtures/html/events.html +171 -0
  45. data/vendor/envjs/test/fixtures/html/iframe1.html +46 -0
  46. data/vendor/envjs/test/fixtures/html/iframe1a.html +46 -0
  47. data/vendor/envjs/test/fixtures/html/iframe2.html +45 -0
  48. data/vendor/envjs/test/fixtures/html/iframe3.html +28 -0
  49. data/vendor/envjs/test/fixtures/html/iframeN.html +57 -0
  50. data/vendor/envjs/test/fixtures/html/malformed.html +181 -0
  51. data/vendor/envjs/test/fixtures/html/scope.html +81 -0
  52. data/vendor/envjs/test/fixtures/html/trivial.html +19 -0
  53. data/vendor/envjs/test/fixtures/html/with_js.html +26 -0
  54. data/vendor/envjs/test/fixtures/images/icon-blue.png +0 -0
  55. data/vendor/envjs/test/fixtures/js/external_script.js +1 -0
  56. data/vendor/envjs/test/fixtures/js/script.js +1 -0
  57. data/vendor/envjs/test/fixtures/js/script_error.js +2 -0
  58. data/vendor/envjs/test/html/events.html +171 -0
  59. data/vendor/envjs/test/html/iframe1.html +46 -0
  60. data/vendor/envjs/test/html/iframe1a.html +46 -0
  61. data/vendor/envjs/test/html/iframe2.html +45 -0
  62. data/vendor/envjs/test/html/iframe3.html +30 -0
  63. data/vendor/envjs/test/html/iframeN.html +57 -0
  64. data/vendor/envjs/test/html/malformed.html +181 -0
  65. data/vendor/envjs/test/html/scope.html +87 -0
  66. data/vendor/envjs/test/html/script.js +1 -0
  67. data/vendor/envjs/test/html/trivial.html +19 -0
  68. data/vendor/envjs/test/html/with_js.html +26 -0
  69. data/vendor/envjs/test/index.html +328 -0
  70. data/vendor/envjs/test/java-prototype.js +9 -0
  71. data/vendor/envjs/test/primary-tests.js +24 -0
  72. data/vendor/envjs/test/prototype-test.js +13 -0
  73. data/vendor/envjs/test/qunit.js +61 -0
  74. data/vendor/envjs/test/qunit/qunit/qunit.css +17 -0
  75. data/vendor/envjs/test/qunit/qunit/qunit.js +997 -0
  76. data/vendor/envjs/test/scope.rb +25 -0
  77. data/vendor/envjs/test/specs/dist/env.spec.js +1534 -0
  78. data/vendor/envjs/test/specs/envjs.spec.css +46 -0
  79. data/vendor/envjs/test/specs/parser/html.js +31 -0
  80. data/vendor/envjs/test/specs/parser/spec.html +40 -0
  81. data/vendor/envjs/test/specs/parser/xml.js +31 -0
  82. data/vendor/envjs/test/specs/qunit.bdd.js +210 -0
  83. data/vendor/envjs/test/specs/qunit.css +17 -0
  84. data/vendor/envjs/test/specs/qunit.js +997 -0
  85. data/vendor/envjs/test/specs/template/spec-0.js +31 -0
  86. data/vendor/envjs/test/specs/template/spec-1.js +31 -0
  87. data/vendor/envjs/test/specs/template/spec.html +40 -0
  88. data/vendor/envjs/test/specs/window/css.js +23 -0
  89. data/vendor/envjs/test/specs/window/dialog.js +25 -0
  90. data/vendor/envjs/test/specs/window/document.js +23 -0
  91. data/vendor/envjs/test/specs/window/event.js +25 -0
  92. data/vendor/envjs/test/specs/window/history.js +34 -0
  93. data/vendor/envjs/test/specs/window/location.js +34 -0
  94. data/vendor/envjs/test/specs/window/navigator.js +71 -0
  95. data/vendor/envjs/test/specs/window/screen.js +42 -0
  96. data/vendor/envjs/test/specs/window/spec.html +48 -0
  97. data/vendor/envjs/test/specs/window/timer.js +26 -0
  98. data/vendor/envjs/test/specs/window/window.js +53 -0
  99. data/vendor/envjs/test/specs/xhr/spec.html +47 -0
  100. data/vendor/envjs/test/specs/xhr/xhr.js +31 -0
  101. data/vendor/envjs/test/test.js +10 -0
  102. data/vendor/envjs/test/unit/dom.js +44 -0
  103. data/vendor/envjs/test/unit/elementmembers.js +60 -0
  104. data/vendor/envjs/test/unit/events.js +195 -0
  105. data/vendor/envjs/test/unit/fixtures/external_script.js +1 -0
  106. data/vendor/envjs/test/unit/iframe.js +234 -0
  107. data/vendor/envjs/test/unit/multi-window.js +212 -0
  108. data/vendor/envjs/test/unit/nu.validator.js +34 -0
  109. data/vendor/envjs/test/unit/onload.js +90 -0
  110. data/vendor/envjs/test/unit/parser.js +121 -0
  111. data/vendor/envjs/test/unit/prototypecompat.js +22 -0
  112. data/vendor/envjs/test/unit/proxy.js +6 -0
  113. data/vendor/envjs/test/unit/scope.js +209 -0
  114. data/vendor/envjs/test/unit/timer.js +115 -0
  115. data/vendor/envjs/test/unit/window.js +41 -0
  116. data/vendor/envjs/test/vendor/jQuery/README +2 -0
  117. data/vendor/envjs/test/vendor/prototype-1.6.0.3.js +4320 -0
  118. metadata +200 -0
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @author thatcher
3
+ */
4
+ var global_scope=this;
5
+
6
+ (function(Q){
7
+
8
+ Q.describe('Window Basic Properties',{
9
+
10
+ before:function(){
11
+ //setup
12
+ },
13
+ after:function(){
14
+ //tear down
15
+ }
16
+
17
+ }).should('provide the required w3c interfaces', function(){
18
+
19
+ expect(19);
20
+ ok(window, 'window');
21
+ ok(self, 'self');
22
+ ok(top, 'top');
23
+ ok(parent, 'parent');
24
+ ok(window.toString(), '[object Window]');
25
+
26
+ //these values are usually the empty string ''
27
+ //so we just verify the property is available
28
+ ok('name' in window, 'name');
29
+ ok('status' in window, 'status');
30
+ ok('closed' in window, 'closed');
31
+ ok('defaultStatus' in window, 'defaultStatus');
32
+ ok('length' in window, 'length');
33
+ ok('opener' in window, 'opener');
34
+
35
+ ok(frames, 'frames');
36
+ ok(open, 'open');
37
+ ok(close, 'close');
38
+ ok(innerHeight, 'innerHeight');
39
+ ok(outerHeight, 'outerHeight');
40
+ ok(outerWidth, 'outerWidth');
41
+ ok(screenX, 'screenX');
42
+ ok(screenY, 'screenY');
43
+
44
+
45
+ }).should('have the expected values', function(){
46
+
47
+ equals( window, global_scope, 'window is the global scope "this"');
48
+ equals( window, self, 'self is an alias for window');
49
+ equals( window, top, 'top is an alias for window when the window is not in a frame');
50
+
51
+ });
52
+
53
+ })(QUnit);
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <title>Envjs Window Spec</title>
6
+ <link rel="stylesheet" media="screen" href="../qunit.css"/>
7
+ <link rel="stylesheet" media="screen" href="../envjs.spec.css"/>
8
+ <link rel="stylesheet" media="screen" href="http://www.envjs.com/css/blueprint/screen.css"/>
9
+ <link rel="stylesheet" media="screen" href="http://www.envjs.com/css/site.css"/>
10
+ <script type='text/javascript' src='../qunit.js'></script>
11
+ <script type='text/javascript' src='../qunit.bdd.js'></script>
12
+
13
+ <!-- specs for this general api 'module' -->
14
+ <script type='text/javascript' src='css.js'></script>
15
+ <script type='text/javascript' src='dialog.js'></script>
16
+ <script type='text/javascript' src='document.js'></script>
17
+ <script type='text/javascript' src='event.js'></script>
18
+ <script type='text/javascript' src='history.js'></script>
19
+ <script type='text/javascript' src='location.js'></script>
20
+ <script type='text/javascript' src='navigator.js'></script>
21
+ <script type='text/javascript' src='window.js'></script>
22
+ <script type='text/javascript' src='timer.js'></script>
23
+ </head>
24
+ <body class='container'>
25
+ <h2 id="qunit-banner">
26
+ <img id="envjs-icon"
27
+ src="../../fixtures/images/icon-blue.png"
28
+ height='40'/>
29
+ <span id="spec-title">Envjs Window Spec</span>
30
+ </h2>
31
+ <h2 id="qunit-userAgent"></h2>
32
+ <div id='qunit-testrunner-toolbar'></div>
33
+ <div id='qunit-test-summary'>
34
+ <ol id='qunit-tests'></ol>
35
+ </div>
36
+ <div id="qunit-main" style="display:none;">
37
+ <!--
38
+ Test HTML here:
39
+
40
+ not required to be in here but it makes it convenient
41
+ by convention to avoid having to look at the html
42
+ artifacts the test may require or have generated as
43
+ a side effect.
44
+ -->
45
+ </div>
46
+ </body>
47
+ </html>
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @author thatcher
3
+ */
4
+
5
+ (function(Q){
6
+
7
+ Q.describe('Another TEMPLATE Spec',{
8
+ before:function(){
9
+ //setup
10
+ },
11
+ after:function(){
12
+ //tear down
13
+ }
14
+
15
+ }).should('do something', function(){
16
+
17
+ expect(1);
18
+ ok(true, 'good job');
19
+
20
+ }).should('do something else', function(){
21
+
22
+ expect(1);
23
+ ok(true, 'good job');
24
+
25
+ }).pending('should do something new soon', function(){
26
+
27
+ expect(1);
28
+ ok(false, 'todo');
29
+ });
30
+
31
+ })(QUnit);
@@ -0,0 +1,10 @@
1
+ whichJarFile = arguments[0];
2
+ whichTestFile = arguments[1];
3
+
4
+ multiwindow = !(whichJarFile == "rhino");
5
+ whichInterpreter = whichJarFile + " interpreter jar";
6
+
7
+ load("dist/env.rhino.js");
8
+ load("test/" + whichTestFile + ".js");
9
+
10
+ Envjs.wait();
@@ -0,0 +1,44 @@
1
+ // dependencies for the tests
2
+ $w = { }
3
+ $env = { debug: function() {} }
4
+ $openingWindow = $parentWindow = $initTop = null;
5
+ this.options = this.options || {}
6
+
7
+ load("src/window/window.js", "src/dom/node.js");
8
+
9
+ debugger;
10
+ module("dom");
11
+
12
+ test("Basic requirements", function() {
13
+ expect(5);
14
+ ok( Array.prototype.push, "Array.push()" );
15
+ ok( Function.prototype.apply, "Function.apply()" );
16
+ ok( document.getElementById, "getElementById" );
17
+ ok( document.getElementsByTagName, "getElementsByTagName" );
18
+ ok( RegExp, "RegExp" );
19
+ });
20
+
21
+
22
+ test("document.getElementById", function() {
23
+ expect(14);
24
+ try{ok (document.getElementById('body').id == "body", "Can get Element by id, expected id='body'");}catch(e){print(e);}
25
+ try{ok (document.getElementById('header').id == "header", "Can get Element by id, expected id='header'");}catch(e){print(e);}
26
+ try{ok (document.getElementById('banner').id == "banner", "Can get Element by id, expected id='banner'");}catch(e){print(e);}
27
+ try{ok (document.getElementById('userAgent').id == "userAgent", "Can get Element by id, expected id='userAgent'");}catch(e){print(e);}
28
+ try{ok (document.getElementById('nothiddendiv').id == "nothiddendiv", "Can get Element by id, expected id='nothiddendiv'");}catch(e){print(e);}
29
+ try{ok (document.getElementById('nothiddendivchild').id == "nothiddendivchild", "Can get Element by id, expected id='nothiddendivchild'");}catch(e){print(e);}
30
+ try{ok (document.getElementById('dl').id == "dl", "Can get Element by id, expected id='dl'");}catch(e){print(e);}
31
+ try{ok (document.getElementById('main').id == "main", "Can get Element by id, expected id='main'");}catch(e){print(e);}
32
+ try{ok (document.getElementById('firstp').id == "firstp", "Can get Element by id, expected id='firstp");}catch(e){print(e);}
33
+ try{ok (document.getElementById('simon1').id == "simon1", "Can get Element by id, expected id='simon1'");}catch(e){print(e);}
34
+ try{ok (document.getElementById('ap').id == "ap", "Can get Element by id, expected id='ap'");}catch(e){print(e);}
35
+ try{ok (document.getElementById('google').id == "google", "Can get Element by id, expected id='google'");}catch(e){print(e);}
36
+ try{ok (document.getElementById('groups').id == "groups", "Can get Element by id, expected id='groups'");}catch(e){print(e);}
37
+ try{ok (document.getElementById('台北Táiběi').id == "台北Táiběi", "Can get Element by UTF-8 id, expected id='台北Táiběi'");}catch(e){print(e);}
38
+ });
39
+
40
+ test("element.getElementsByTagName", function() {
41
+ expect(1);
42
+ var body = document.getElementById('body');
43
+ try{ok (body.getElementsByTagName('h1').length == 1, "Can get NodeList length : Expected 1 , Got " + body.getElementsByTagName('h1').length);}catch(e){print(e);}
44
+ });
@@ -0,0 +1,60 @@
1
+ module("elementmembers");
2
+
3
+ // We ought to have test coverage for all members of all DOM objects, but
4
+ // until then, add test cases here for members as they are created
5
+
6
+ test("attributes common to all HTML elements", function() {
7
+ expect(4);
8
+
9
+ // tests for .innerText
10
+ var mtch = document.getElementById('dl').innerText.match(
11
+ /^\s+See this blog entry for more information.\s+Here are/);
12
+ try{ ok(mtch && mtch.length > 0,
13
+ "dl.innerText returns the correct content");
14
+ }catch(e){print(e);}
15
+
16
+ mtch = document.getElementById('sndp').innerText.match(/^Everything insid/);
17
+ try{ ok(mtch && mtch.length > 0,
18
+ "p.innerText returns the correct content");
19
+ }catch(e){print(e);}
20
+
21
+ try{ ok(document.getElementById('sndp').innerText = "test text" || true,
22
+ "p.innerText= operates without exception");
23
+ }catch(e){print(e);}
24
+
25
+ try{ ok(document.getElementById('sndp').innerText == "test text",
26
+ "p.innerText= changes content of element");
27
+ }catch(e){print(e);}
28
+ });
29
+
30
+ test("select element", function() {
31
+ expect(14);
32
+
33
+ var select = document.getElementById('select1');
34
+ equals("select-one", select.type, "Select field's type is select-one by default");
35
+
36
+ select = document.getElementById('test_value');
37
+ equals("optionvalue", select.value, "Select field returns its selected option's value as its value");
38
+
39
+ // if option2 is selected, unselect option1 (and update select.value)
40
+ select = document.getElementById('test_selecting');
41
+ select.options[2].selected = true;
42
+ ok(select.options[2].selected, "Select's option should be selected");
43
+ ok(!select.options[1].selected, "Previously selected option should be automatically unselected");
44
+ equals("2", select.value, "Select's value should be updated");
45
+
46
+ // if option2 is unselected, then select first option on the list (and update select.value)
47
+ select.options[2].selected = false;
48
+ ok(!select.options[2].selected, "Select's option should be unselected");
49
+ ok(!select.options[1].selected, "Previously selected option should stay unselected");
50
+ ok(select.options[0].selected, "First option in the select should be selected");
51
+ equals("0", select.value, "Select's value should be updated");
52
+
53
+ // update select's value and options when selectedIndex is changed
54
+ equals(0, select.selectedIndex, "Select's selectedIndex should return the index of selected option");
55
+ select.selectedIndex = 2;
56
+ equals(2, select.selectedIndex, "Select's selectedIndex should be updated");
57
+ equals("2", select.value, "Changing selectedIndex should update select's value");
58
+ ok(!select.options[0].selected, "Changing selectedIndex should unselect currently selected option");
59
+ ok(select.options[2].selected, "Changing selectedIndex should select option at given index");
60
+ });
@@ -0,0 +1,195 @@
1
+ /*
2
+ * This file is a component of env.js,
3
+ * http://github.com/gleneivey/env-js/commits/master/README
4
+ * a Pure JavaScript Browser Environment
5
+ * Copyright 2009 John Resig, licensed under the MIT License
6
+ * http://www.opensource.org/licenses/mit-license.php
7
+ */
8
+
9
+
10
+ module("events");
11
+
12
+ // This file is for tests of general event dispatching, propagation, and
13
+ // handling functionality. In keeping with the general non-exhaustive
14
+ // approach of env.js's unit tests, each behavior is checked for one
15
+ // relevant type of event in one relevant context (page structure, etc.).
16
+
17
+ // These tests rely on the content of ../html/events.html and of the
18
+ // <iframe id='eventsFrame'> tag in ../index.html.
19
+
20
+ // These tests are order-dependent. If you alter the order or add new tests
21
+ // in the middle, the expected values of eventFrameLoaded and
22
+ // eventFrameClicked may well change (perhaps requiring extra parameters
23
+ // to the *Checks convenience functions).
24
+
25
+
26
+ var __click__ = function(element){
27
+ var event = new Event({
28
+ target:element,
29
+ currentTarget:element
30
+ });
31
+ event.initEvent("click");
32
+ element.dispatchEvent(event);
33
+ }
34
+
35
+ function loadChecks(tag, loadCount, imgCount, unloadCount){
36
+ expect(5);
37
+
38
+ var eCounters = window.top.eCounters;
39
+ try{ ok( eCounters["window onload"] == loadCount &&
40
+ eCounters["body onload"] == loadCount,
41
+ tag + ": Onload Events recorded");
42
+ }catch(e){print(e);}
43
+
44
+ try{ ok( eCounters["img onload"] == imgCount,
45
+ tag + ": Img-tag onload event(s) recorded separately");
46
+ }catch(e){print(e);}
47
+
48
+ try{ ok( eCounters["window onunload"] == unloadCount &&
49
+ eCounters["body onunload"] == unloadCount,
50
+ tag + ": Onunload events recorded");
51
+ }catch(e){print(e);}
52
+
53
+ try{ ok( eCounters["body onclick"] == 0 &&
54
+ eCounters["h1 onclick"] == 0 &&
55
+ eCounters["h2 onclick"] == 0 &&
56
+ eCounters["div onclick"] == 0 &&
57
+ eCounters["table onclick"] == 0 &&
58
+ eCounters["tbody onclick"] == 0 &&
59
+ eCounters["tr onclick"] == 0 &&
60
+ eCounters["td onclick"] == 0 &&
61
+ eCounters["ul onclick"] == 0 &&
62
+ eCounters["li onclick"] == 0 &&
63
+ eCounters["p onclick"] == 0 &&
64
+ eCounters["b onclick"] == 0 &&
65
+ eCounters["i onclick"] == 0 &&
66
+ eCounters["a onclick"] == 0 &&
67
+ eCounters["img onclick"] == 0,
68
+ tag + ": Onload events recorded once.");
69
+ }catch(e){print(e);}
70
+
71
+ try{ ok( eventFrameLoaded == loadCount && eventFrameClicked == 0,
72
+ tag + ": " + loadCount + " iframe events recorded on page load.");
73
+ }catch(e){print(e);}
74
+ }
75
+
76
+
77
+ test("Check that events do/don't occur on document load", function() {
78
+ // eCounters already initialized by code in ../html/events.html
79
+ loadChecks("Load", 1, 1, 0);
80
+ });
81
+
82
+ test("Check that events do/don't occur on manual iframe reload", function() {
83
+ document.getElementById('eventsFrame').src = "html/events.html";
84
+ loadChecks("Reload", 2, 2, 1);
85
+ });
86
+
87
+ test("Check that an event which should NOT bubble actually does not",
88
+ function() {
89
+ var img = document.getElementById('eventsFrame').contentDocument.
90
+ getElementById('theIMG').src = "missing.png";
91
+ loadChecks("Img Load", 2, 3, 1);
92
+
93
+ // note: if img-onload had bubbled up, previous tests probably would
94
+ // have failed (too large body-onload counts), too. So this test
95
+ // just ensures that operation is correct even when only part of
96
+ // page is reloading.
97
+ });
98
+
99
+
100
+
101
+ function clickChecks(tag, upperCount, lowerCount){
102
+ expect(5);
103
+
104
+ var eCounters = window.top.eCounters;
105
+ try{ ok( eCounters["window onload"] == 0 &&
106
+ eCounters["window onunload"] == 0 &&
107
+ eCounters["body onload"] == 0 &&
108
+ eCounters["body onunload"] == 0 &&
109
+ eCounters["img onload"] == 0,
110
+ tag + ": Onload events not triggered by click");
111
+ }catch(e){print(e);}
112
+
113
+ var special = (upperCount == lowerCount) ? "" : " not";
114
+ try{ ok( eCounters["ul onclick"] == lowerCount &&
115
+ eCounters["li onclick"] == lowerCount &&
116
+ eCounters["p onclick"] == lowerCount &&
117
+ eCounters["b onclick"] == lowerCount &&
118
+ eCounters["i onclick"] == lowerCount &&
119
+ eCounters["a onclick"] == lowerCount &&
120
+ eCounters["img onclick"] == lowerCount,
121
+ tag + ": Click event did" + special + " bubble through inner elements");
122
+ }catch(e){print(e);}
123
+
124
+ try{ ok( eCounters["body onclick"] == upperCount &&
125
+ eCounters["div onclick"] == upperCount &&
126
+ eCounters["table onclick"] == upperCount &&
127
+ eCounters["tbody onclick"] == upperCount &&
128
+ eCounters["tr onclick"] == upperCount &&
129
+ eCounters["td onclick"] == upperCount,
130
+ tag + ": Click event bubbled through outer elements");
131
+ }catch(e){print(e);}
132
+
133
+ try{ ok( eCounters["h1 onclick"] == 0 &&
134
+ eCounters["h2 onclick"] == 0,
135
+ tag + ": No click events for Hx elements");
136
+ }catch(e){print(e);}
137
+
138
+
139
+ try{ ok( eventFrameLoaded == 2 && eventFrameClicked == 0,
140
+ tag + ": Iframe event counts unchanged");
141
+ }catch(e){print(e);}
142
+ }
143
+
144
+ test("Check that an event which should bubble actually does", function() {
145
+ // clear in-iframe event counters to zero
146
+ window.top.eCounters = {};
147
+ fWin = document.getElementById('eventsFrame').contentWindow;
148
+ fWin.initECounters(window.top.eCounters);
149
+
150
+ // simulate a "click" user action
151
+ var img = document.getElementById('eventsFrame').contentDocument.
152
+ getElementById('theIMG');
153
+ __click__(img);
154
+
155
+ clickChecks("Click img", 1, 1);
156
+ });
157
+
158
+ test("Bubbling event ONLY bubbles 'up'", function() {
159
+ // simulate a "click" user action
160
+ var td = document.getElementById('eventsFrame').contentDocument.
161
+ getElementById('theTD');
162
+ __click__(td);
163
+
164
+ clickChecks("Click td", 2, 1);
165
+ });
166
+
167
+
168
+ test("Check that events can be set with addEventListener(), and bubble",
169
+ function() {
170
+ expect(4);
171
+
172
+ var img = document.getElementById('eventsFrame').contentDocument.
173
+ getElementById('theIMG');
174
+
175
+ // add handlers
176
+ addHdlr = function(id) {
177
+ var elem = document.getElementById('eventsFrame').contentDocument.
178
+ getElementById(id).addEventListener('click', function(event){
179
+ try{
180
+ ok( event.target === img && ( ( this === window ) || ( this.window === window ) ),
181
+ "Scope: 'this' refers to the window '" + window + "'");
182
+ }catch(e){print(e);}
183
+ });
184
+ };
185
+
186
+ // a few objects that the <img 'theImG'>.click event will bubble up through
187
+ addHdlr("theIMG");
188
+ addHdlr("theA");
189
+ addHdlr("theP");
190
+ addHdlr("theLI");
191
+
192
+ // simulate user action
193
+ __click__(img);
194
+ });
195
+