envjs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/README +113 -0
  2. data/bin/envjsrb +239 -0
  3. data/bin/jquery-1.2.6-test.js +33 -0
  4. data/bin/jquery-1.3.1-test.js +33 -0
  5. data/bin/jquery-1.3.2-test.js +106 -0
  6. data/bin/prototype-1.6.0.3-test.js +82 -0
  7. data/bin/prototype_1.6.0.3_tmpl.txt +27 -0
  8. data/bin/test-jquery.sh +58 -0
  9. data/bin/test-prototype.sh +54 -0
  10. data/bin/tidy +0 -0
  11. data/lib/envjs/env.js +21549 -0
  12. data/lib/envjs/net/cgi.rb +94 -0
  13. data/lib/envjs/net/file.rb +75 -0
  14. data/lib/envjs/net.rb +3 -0
  15. data/lib/envjs/options.rb +11 -0
  16. data/lib/envjs/runtime.rb +280 -0
  17. data/lib/envjs/tempfile.rb +24 -0
  18. data/lib/envjs.rb +23 -0
  19. data/test/call-load-test.js +15 -0
  20. data/test/debug.js +53 -0
  21. data/test/firebug/errorIcon.png +0 -0
  22. data/test/firebug/firebug.css +209 -0
  23. data/test/firebug/firebug.html +23 -0
  24. data/test/firebug/firebug.js +672 -0
  25. data/test/firebug/firebugx.js +10 -0
  26. data/test/firebug/infoIcon.png +0 -0
  27. data/test/firebug/warningIcon.png +0 -0
  28. data/test/fixtures/html/events.html +171 -0
  29. data/test/fixtures/html/iframe1.html +46 -0
  30. data/test/fixtures/html/iframe1a.html +46 -0
  31. data/test/fixtures/html/iframe2.html +45 -0
  32. data/test/fixtures/html/iframe3.html +28 -0
  33. data/test/fixtures/html/iframeN.html +57 -0
  34. data/test/fixtures/html/malformed.html +181 -0
  35. data/test/fixtures/html/scope.html +81 -0
  36. data/test/fixtures/html/trivial.html +19 -0
  37. data/test/fixtures/html/with_js.html +26 -0
  38. data/test/fixtures/images/icon-blue.png +0 -0
  39. data/test/fixtures/js/external_script.js +1 -0
  40. data/test/fixtures/js/script.js +1 -0
  41. data/test/fixtures/js/script_error.js +2 -0
  42. data/test/html/events.html +171 -0
  43. data/test/html/iframe1.html +46 -0
  44. data/test/html/iframe1a.html +46 -0
  45. data/test/html/iframe2.html +45 -0
  46. data/test/html/iframe3.html +30 -0
  47. data/test/html/iframeN.html +57 -0
  48. data/test/html/malformed.html +181 -0
  49. data/test/html/scope.html +87 -0
  50. data/test/html/script.js +1 -0
  51. data/test/html/trivial.html +19 -0
  52. data/test/html/with_js.html +26 -0
  53. data/test/index.html +328 -0
  54. data/test/java-prototype.js +9 -0
  55. data/test/primary-tests.js +24 -0
  56. data/test/prototype-test.js +13 -0
  57. data/test/qunit/qunit/qunit.css +17 -0
  58. data/test/qunit/qunit/qunit.js +997 -0
  59. data/test/qunit.js +61 -0
  60. data/test/specs/dist/env.spec.js +1534 -0
  61. data/test/specs/envjs.spec.css +46 -0
  62. data/test/specs/parser/html.js +31 -0
  63. data/test/specs/parser/spec.html +40 -0
  64. data/test/specs/parser/xml.js +31 -0
  65. data/test/specs/qunit.bdd.js +210 -0
  66. data/test/specs/qunit.css +17 -0
  67. data/test/specs/qunit.js +997 -0
  68. data/test/specs/template/spec-0.js +31 -0
  69. data/test/specs/template/spec-1.js +31 -0
  70. data/test/specs/template/spec.html +40 -0
  71. data/test/specs/window/css.js +23 -0
  72. data/test/specs/window/dialog.js +25 -0
  73. data/test/specs/window/document.js +23 -0
  74. data/test/specs/window/event.js +25 -0
  75. data/test/specs/window/history.js +34 -0
  76. data/test/specs/window/location.js +34 -0
  77. data/test/specs/window/navigator.js +71 -0
  78. data/test/specs/window/screen.js +42 -0
  79. data/test/specs/window/spec.html +48 -0
  80. data/test/specs/window/timer.js +26 -0
  81. data/test/specs/window/window.js +53 -0
  82. data/test/specs/xhr/spec.html +47 -0
  83. data/test/specs/xhr/xhr.js +31 -0
  84. data/test/test.js +10 -0
  85. data/test/unit/dom.js +44 -0
  86. data/test/unit/elementmembers.js +60 -0
  87. data/test/unit/events.js +195 -0
  88. data/test/unit/fixtures/external_script.js +1 -0
  89. data/test/unit/iframe.js +234 -0
  90. data/test/unit/multi-window.js +212 -0
  91. data/test/unit/nu.validator.js +34 -0
  92. data/test/unit/onload.js +90 -0
  93. data/test/unit/parser.js +121 -0
  94. data/test/unit/prototypecompat.js +22 -0
  95. data/test/unit/proxy.js +6 -0
  96. data/test/unit/scope.js +209 -0
  97. data/test/unit/timer.js +115 -0
  98. data/test/unit/window.js +41 -0
  99. data/test/vendor/jQuery/README +2 -0
  100. data/test/vendor/prototype-1.6.0.3.js +4320 -0
  101. metadata +164 -0
@@ -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
+
@@ -0,0 +1 @@
1
+ var $$$$$ = "12345";
@@ -0,0 +1,234 @@
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("iframe");
11
+
12
+
13
+ // In general, the tests here use the files ../html/iframe*.html
14
+ // I've tried to keep all of the id attributes and text fragments in these
15
+ // files unique from each other and from the content of index.html
16
+ // to ensure that we can correctly identify which file has loaded into
17
+ // which frame/window. When making modifications/additions, paying
18
+ // attention to uniqueness is recommended.
19
+
20
+
21
+ // all tests to next comment rely on content of ../html/iframe1.html and
22
+ // ../html/iframe1a.html
23
+
24
+ // iframe1 and iframe1a are identical in structure (so we can use the
25
+ // same assertions against both), but different in content text (so
26
+ // that we can tell which one is currently loaded). So, create an
27
+ // object (associative array) that is specific to the content of each.
28
+ contentOfIframe1 = {
29
+ url : "html/iframe1.html",
30
+ titleRE : /IFRAME/,
31
+ elementId : 'anElementWithText',
32
+ elementRE : /content of a paragraph/
33
+ };
34
+ contentOfIframe1a = {
35
+ url : "html/iframe1a.html",
36
+ titleRE : /iframe1a.html/,
37
+ elementId : 'anotherElementWithText',
38
+ elementRE : /block-quote element/
39
+ };
40
+
41
+ var accessChecksForIframe1 = function(flag, iframe, contentOf) {
42
+ expect(6);
43
+
44
+ try{ok (iframe.src == contentOf.url,
45
+ flag + ": Initial iframe src matches test page source");
46
+ }catch(e){print(e);}
47
+
48
+ var idoc = iframe.contentDocument;
49
+ var mtch = idoc.title.match(contentOf.titleRE);
50
+ try{ok (mtch && mtch.length > 0,
51
+ flag + ": Can get 'document' object from test iframe");
52
+ }catch(e){print(e);}
53
+
54
+ var para = idoc.getElementById(contentOf.elementId);
55
+ mtch = para.innerHTML.match(contentOf.elementRE);
56
+ try{ok (mtch && mtch.length > 0,
57
+ flag + ": Can get text from element in an iframe");
58
+ }catch(e){print(e);}
59
+
60
+ try{ok (idoc.parentWindow == iframe.contentWindow,
61
+ flag + ": doc's .parentWindow points to iframe's .contentWindow");
62
+ }catch(e){print(e);}
63
+
64
+ try{ok (idoc.parentWindow.parent == window,
65
+ flag + ": Can follow chain from iframe's doc to containing window");
66
+ }catch(e){print(e);}
67
+
68
+ try{ok (iframe.contentWindow.top == window,
69
+ flag + ": '.top' from iframe does point to top window");
70
+ }catch(e){print(e);}
71
+ };
72
+
73
+ test("IFRAMEs load with accessible content", function() {
74
+ var iframe = document.getElementById('loadediframe');
75
+ // iframe1.html loaded via src= attribute when index.html was parsed
76
+ accessChecksForIframe1("1", iframe, contentOfIframe1);
77
+ });
78
+
79
+
80
+ test("IFRAMEs still load when .src is set after the page is parsed",function() {
81
+ var iframe = document.getElementById('emptyiframe');
82
+ iframe.src = "html/iframe1.html";
83
+ accessChecksForIframe1("2", iframe, contentOfIframe1);
84
+ });
85
+
86
+ test("IFRAMEs reload with accessible content", function() {
87
+ var iframe = document.getElementById('loadediframe');
88
+ iframe.src = "html/iframe1a.html";
89
+ accessChecksForIframe1("3", iframe, contentOfIframe1a);
90
+ });
91
+
92
+
93
+ // this test relies on iframe3.html, iframe2.html, and iframeN.html
94
+ test("IFRAMEs can be nested, created dynamically", function() {
95
+ var startingDepth = 3;
96
+ var endingDepth = 7;
97
+ expect(5 + (10*((endingDepth - startingDepth)+1)));
98
+
99
+ // manually load iframe3.html
100
+ var firstIframe = document.getElementById('emptyiframe');
101
+ firstIframe.src = "html/iframe3.html";
102
+
103
+ // iframe3.html contains a static <iframe> element that loads iframe2.html,
104
+ // so at this point, we should have both loaded, with the structure that
105
+ // index.html --contains--> iframe3.html --contains--> iframe2.html
106
+ // w/ id's = emptyiframe nested1Level
107
+
108
+
109
+
110
+ ////////////////////////////////////////
111
+ // first, verify that we've got the structure we expect:
112
+ var mtch = firstIframe.contentDocument.title.match(/nested-IFRAME/);
113
+ try{ok (mtch && mtch.length > 0,
114
+ "top-level IFRAME reloaded from correct source");
115
+ }catch(e){print(e);}
116
+
117
+ var secondIframe = firstIframe.contentDocument.
118
+ getElementById('nested1Level');
119
+ mtch = secondIframe.contentDocument.title.match(/IFRAME loading/);
120
+ try{ok (mtch && mtch.length > 0,
121
+ "can access content of an IFRAME nested in another");
122
+ }catch(e){print(e);}
123
+
124
+ try{ok (secondIframe.contentDocument.parentWindow.parent.parent == window,
125
+ "can follow path from nested IFRAME to root window");
126
+ }catch(e){print(e);}
127
+
128
+ try{ok (secondIframe.contentWindow.parent.parent == window,
129
+ "also path through .contentWindow to root window");
130
+ }catch(e){print(e);}
131
+
132
+ try{ok (secondIframe.contentWindow.top == window,
133
+ "nested IFRAME has correct .top");
134
+ }catch(e){print(e);}
135
+
136
+
137
+ ////////////////////////////////////////
138
+ // OK, now we'll programatically extend the nesting depth from 2 to many
139
+ window.numberNestedIframeLoads = 0;
140
+ window.winLoadCount = 0;
141
+ window.bodyLoadCount = 0;
142
+ window.frameLoadCount = 0;
143
+ for (var c = startingDepth, bottomIframe = secondIframe; c <= endingDepth;
144
+ c++){
145
+
146
+ // add a new iframe within the current leaf iframe
147
+ var newIframe = bottomIframe.contentDocument.createElement("iframe");
148
+ newIframe.setAttribute("id", "iframe_of_depth_" + c);
149
+ newIframe.setAttribute("onload", "iframeOnloadHandler();");
150
+ var bottomBody = bottomIframe.contentDocument.
151
+ getElementsByTagName('body')[0];
152
+
153
+ bottomBody.appendChild(newIframe);
154
+ newIframe.src = "html/iframeN.html";
155
+ bottomIframe = newIframe;
156
+
157
+
158
+
159
+ ////////////////////////////////////////
160
+ // verify contents of just-loaded iframe
161
+ mtch = bottomIframe.contentDocument.getElementById('nestingLevel').
162
+ innerHTML.match(/[0-9]+/);
163
+ try{ok (mtch && mtch.length > 0 && parseInt(mtch[0]) == c,
164
+ "nested " + c + " levels: can access content");
165
+ }catch(e){print(e);}
166
+
167
+ for (var aWindow = bottomIframe.contentWindow, cn = c; cn > 0; cn--)
168
+ aWindow = aWindow.parent;
169
+ try{ok (aWindow == window,
170
+ "nested " + c + " levels: can follow path to root window");
171
+ }catch(e){print(e);}
172
+
173
+ try{ok (bottomIframe.contentWindow.top == window,
174
+ "nested " + c + " levels: IFRAME has correct .top");
175
+ }catch(e){print(e);}
176
+
177
+
178
+
179
+ ////////////////////////////////////////
180
+ // verify events related to iframe load:
181
+ // iframe.onload (container); window.onload and body.onload (contained)
182
+ var num = (c - startingDepth) + 1;
183
+ try{ok (num == window.numberNestedIframeLoads,
184
+ "nested " + c + " levels: event <script> executed");
185
+ }catch(e){print(e);}
186
+
187
+ try{ok (num == window.winLoadCount,
188
+ "nested " + c + " levels: window-onload handler executed");
189
+ }catch(e){print(e);}
190
+ try{ok (num == window.bodyLoadCount,
191
+ "nested " + c + " levels: body-onload handler executed");
192
+ }catch(e){print(e);}
193
+ try{ok (num == window.frameLoadCount,
194
+ "nested " + c + " levels: iframe-onload handler executed");
195
+ }catch(e){print(e);}
196
+
197
+ mtch = bottomIframe.contentWindow.parent.document.
198
+ getElementById("pCreatedIframeOnload" + num).innerHTML.
199
+ match(/para iframe onload ([0-9]+)/);
200
+ try{ok (mtch && mtch.length > 0 && parseInt(mtch[1]) == num,
201
+ "nested " + c + " levels: confirmed iframe-onload");
202
+ }catch(e){print(e);}
203
+ mtch = bottomIframe.contentDocument.
204
+ getElementById("pCreatedWindowOnload" + num).innerHTML.
205
+ match(/para window onload ([0-9]+)/);
206
+ try{ok (mtch && mtch.length > 0 && parseInt(mtch[1]) == num,
207
+ "nested " + c + " levels: confirmed window-onload");
208
+ }catch(e){print(e);}
209
+ mtch = bottomIframe.contentDocument.
210
+ getElementById("pCreatedBodyOnload" + num).innerHTML.
211
+ match(/para body onload ([0-9]+)/);
212
+ try{ok (mtch && mtch.length > 0 && parseInt(mtch[1]) == num,
213
+ "nested " + c + " levels: confirmed body-onload");
214
+ }catch(e){print(e);}
215
+ }
216
+ });
217
+
218
+
219
+ // all tests to next comment rely on content of ../html/iframe2.html
220
+ test("IFRAMEs reload on assignment to 'src'", function() {
221
+ expect(2);
222
+
223
+ var iframe = document.getElementById('loadediframe');
224
+ iframe.src = "html/iframe2.html";
225
+ try{ok (iframe.src == "html/iframe2.html",
226
+ "iframe.src matches value assigned");
227
+ }catch(e){print(e);}
228
+
229
+ var para = iframe.contentDocument.getElementById('aParaInAnIframe');
230
+ var mtch = para.innerHTML.match(/short paragraph/);
231
+ try{ok (mtch && mtch.length > 0,
232
+ "IFRAME reloaded from correct source");
233
+ }catch(e){print(e);}
234
+ });