envjs19 0.3.8.20101029121421
Sign up to get free protection for your applications and to get access to all the features.
- data/.jslintrbrc +30 -0
- data/.project +17 -0
- data/CHANGELOG.rdoc +57 -0
- data/DTD/xhtml-lat1.ent +196 -0
- data/DTD/xhtml-special.ent +80 -0
- data/DTD/xhtml-symbol.ent +237 -0
- data/DTD/xhtml.soc +14 -0
- data/DTD/xhtml1-frameset.dtd +1235 -0
- data/DTD/xhtml1-strict.dtd +978 -0
- data/DTD/xhtml1-transitional.dtd +1201 -0
- data/DTD/xhtml1.dcl +192 -0
- data/Makefile +7 -0
- data/Manifest.txt +280 -0
- data/README.rdoc +65 -0
- data/Rakefile +196 -0
- data/Wakefile +11 -0
- data/bin/envjsrb +257 -0
- data/build.properties +9 -0
- data/build.xml +247 -0
- data/gm/jquery.js +6002 -0
- data/gm/mainx.js +2648 -0
- data/gm/sensx.js +135 -0
- data/gm/t.js +6 -0
- data/gm/x.html +76 -0
- data/htmlparser/BrowserTreeBuilder.java +456 -0
- data/htmlparser/README +34 -0
- data/htmlparser/build.sh +38 -0
- data/jsl/jsl +0 -0
- data/jsl/jsl.default.conf +129 -0
- data/jsl/jsl.exe +0 -0
- data/lib/envjs.rb +35 -0
- data/lib/envjs/event_loop.js +206 -0
- data/lib/envjs/net.rb +3 -0
- data/lib/envjs/net/cgi.rb +94 -0
- data/lib/envjs/net/file.rb +69 -0
- data/lib/envjs/options.rb +11 -0
- data/lib/envjs/runtime.rb +346 -0
- data/lib/envjs/tempfile.rb +24 -0
- data/licenses/GPL-LICENSE.txt +278 -0
- data/licenses/MIT-LICENSE.txt +20 -0
- data/src/base64.js +80 -0
- data/src/build.js +6 -0
- data/src/cruft/bad.html +24 -0
- data/src/cruft/dom.js +606 -0
- data/src/cruft/element.js +297 -0
- data/src/cruft/good.html +30 -0
- data/src/cruft/good.js +32 -0
- data/src/cruft/internal.js +81 -0
- data/src/cruft/parser.js +458 -0
- data/src/css/properties.js +293 -0
- data/src/css/rule.js +22 -0
- data/src/css/sizzle.js +717 -0
- data/src/css/stylesheet.js +52 -0
- data/src/dom/attr.js +55 -0
- data/src/dom/cdatasection.js +31 -0
- data/src/dom/characterdata.js +119 -0
- data/src/dom/comment.js +30 -0
- data/src/dom/doctype.js +9 -0
- data/src/dom/document.js +1023 -0
- data/src/dom/dom.js +134 -0
- data/src/dom/element.js +217 -0
- data/src/dom/entities.js +273 -0
- data/src/dom/exception.js +28 -0
- data/src/dom/fragment.js +37 -0
- data/src/dom/implementation.js +140 -0
- data/src/dom/instruction.js +51 -0
- data/src/dom/namednodemap.js +374 -0
- data/src/dom/namespace.js +50 -0
- data/src/dom/node.js +618 -0
- data/src/dom/nodelist.js +195 -0
- data/src/dom/parser.js +1207 -0
- data/src/dom/text.js +73 -0
- data/src/event/event.js +47 -0
- data/src/event/mouseevent.js +4 -0
- data/src/event/uievent.js +8 -0
- data/src/html/a.js +110 -0
- data/src/html/anchor.js +80 -0
- data/src/html/area.js +57 -0
- data/src/html/base.js +26 -0
- data/src/html/blockquote-q.js +19 -0
- data/src/html/body.js +19 -0
- data/src/html/button.js +21 -0
- data/src/html/canvas.js +14 -0
- data/src/html/col-colgroup.js +49 -0
- data/src/html/collection.js +72 -0
- data/src/html/cookie.js +153 -0
- data/src/html/del-ins.js +25 -0
- data/src/html/div.js +28 -0
- data/src/html/document.js +364 -0
- data/src/html/element.js +382 -0
- data/src/html/fieldset.js +19 -0
- data/src/html/form.js +484 -0
- data/src/html/frame.js +89 -0
- data/src/html/frameset.js +25 -0
- data/src/html/head.js +44 -0
- data/src/html/html.js +0 -0
- data/src/html/htmlparser.js +340 -0
- data/src/html/iframe.js +26 -0
- data/src/html/image.js +0 -0
- data/src/html/img.js +62 -0
- data/src/html/input-elements.js +307 -0
- data/src/html/input.js +65 -0
- data/src/html/label.js +26 -0
- data/src/html/legend.js +19 -0
- data/src/html/link.js +82 -0
- data/src/html/map.js +22 -0
- data/src/html/meta.js +37 -0
- data/src/html/object.js +89 -0
- data/src/html/optgroup.js +25 -0
- data/src/html/option.js +103 -0
- data/src/html/param.js +38 -0
- data/src/html/script.js +122 -0
- data/src/html/select.js +132 -0
- data/src/html/style.js +31 -0
- data/src/html/table.js +199 -0
- data/src/html/tbody-thead-tfoot.js +92 -0
- data/src/html/td-th.js +18 -0
- data/src/html/textarea.js +31 -0
- data/src/html/title.js +20 -0
- data/src/html/tr.js +114 -0
- data/src/intro.js +141 -0
- data/src/outro.js +70 -0
- data/src/parser/html5.detailed.js +10762 -0
- data/src/parser/html5.min.js +503 -0
- data/src/parser/html5.pretty.js +10815 -0
- data/src/parser/intro.js +42 -0
- data/src/parser/outro.js +9 -0
- data/src/platform/core.js +323 -0
- data/src/platform/johnson.js +484 -0
- data/src/platform/rhino.js +327 -0
- data/src/platform/static/intro.js +41 -0
- data/src/platform/static/outro.js +30 -0
- data/src/profile/aop.js +238 -0
- data/src/profile/profile.js +402 -0
- data/src/serializer/xml.js +21 -0
- data/src/svg/animatedstring.js +25 -0
- data/src/svg/document.js +25 -0
- data/src/svg/element.js +22 -0
- data/src/svg/locatable.js +17 -0
- data/src/svg/rect.js +18 -0
- data/src/svg/rectelement.js +24 -0
- data/src/svg/stylable.js +49 -0
- data/src/svg/svgelement.js +22 -0
- data/src/svg/transformable.js +15 -0
- data/src/window/css.js +15 -0
- data/src/window/dialog.js +16 -0
- data/src/window/document.js +28 -0
- data/src/window/event.js +265 -0
- data/src/window/history.js +62 -0
- data/src/window/location.js +156 -0
- data/src/window/navigator.js +48 -0
- data/src/window/screen.js +53 -0
- data/src/window/timer.js +21 -0
- data/src/window/window.js +284 -0
- data/src/window/xhr.js +135 -0
- data/src/xpath/expression.js +49 -0
- data/src/xpath/implementation.js +2505 -0
- data/src/xpath/result.js +67 -0
- data/src/xpath/util.js +551 -0
- data/src/xpath/xmltoken.js +149 -0
- data/src/xslt/COPYING +34 -0
- data/src/xslt/ajaxslt-0.8.1/AUTHORS +1 -0
- data/src/xslt/ajaxslt-0.8.1/ChangeLog +136 -0
- data/src/xslt/ajaxslt-0.8.1/Makefile +49 -0
- data/src/xslt/ajaxslt-0.8.1/README +102 -0
- data/src/xslt/ajaxslt-0.8.1/TODO +15 -0
- data/src/xslt/ajaxslt-0.8.1/dom.js +566 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.html +24 -0
- data/src/xslt/ajaxslt-0.8.1/dom_unittest.js +131 -0
- data/src/xslt/ajaxslt-0.8.1/simplelog.js +79 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/test/xpath_script.js +45 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt.html +58 -0
- data/src/xslt/ajaxslt-0.8.1/test/xslt_script.js +33 -0
- data/src/xslt/ajaxslt-0.8.1/unittestsuite.html +26 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken.js +149 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.html +18 -0
- data/src/xslt/ajaxslt-0.8.1/xmltoken_unittest.js +811 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.html +39 -0
- data/src/xslt/ajaxslt-0.8.1/xpath_unittest.js +557 -0
- data/src/xslt/ajaxslt-0.8.1/xpathdebug.js +234 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.html +138 -0
- data/src/xslt/ajaxslt-0.8.1/xslt_unittest.js +68 -0
- data/src/xslt/implementation.js +625 -0
- data/src/xslt/processor.js +37 -0
- data/src/xslt/util.js +449 -0
- data/test/base64.js +80 -0
- data/test/call-load-test.js +15 -0
- data/test/data.js +45 -0
- data/test/debug.js +53 -0
- data/test/firebug/errorIcon.png +0 -0
- data/test/firebug/firebug.css +209 -0
- data/test/firebug/firebug.html +23 -0
- data/test/firebug/firebug.js +672 -0
- data/test/firebug/firebugx.js +10 -0
- data/test/firebug/infoIcon.png +0 -0
- data/test/firebug/warningIcon.png +0 -0
- data/test/fixtures/html/events.html +171 -0
- data/test/fixtures/html/iframe1.html +46 -0
- data/test/fixtures/html/iframe1a.html +46 -0
- data/test/fixtures/html/iframe2.html +45 -0
- data/test/fixtures/html/iframe3.html +28 -0
- data/test/fixtures/html/iframeN.html +57 -0
- data/test/fixtures/html/malformed.html +181 -0
- data/test/fixtures/html/scope.html +81 -0
- data/test/fixtures/html/trivial.html +19 -0
- data/test/fixtures/html/with_js.html +26 -0
- data/test/fixtures/images/icon-blue.png +0 -0
- data/test/fixtures/js/external_script.js +1 -0
- data/test/fixtures/js/script.js +1 -0
- data/test/fixtures/js/script_error.js +2 -0
- data/test/foo.html +8 -0
- data/test/foo.js +40 -0
- data/test/html/events.html +171 -0
- data/test/html/iframe1.html +46 -0
- data/test/html/iframe1a.html +46 -0
- data/test/html/iframe2.html +45 -0
- data/test/html/iframe3.html +30 -0
- data/test/html/iframeN.html +57 -0
- data/test/html/malformed.html +181 -0
- data/test/html/scope.html +87 -0
- data/test/html/script.js +1 -0
- data/test/html/trivial.html +19 -0
- data/test/html/with_js.html +26 -0
- data/test/index.html +328 -0
- data/test/java-prototype.js +9 -0
- data/test/jquery.js +6002 -0
- data/test/primary-tests.js +26 -0
- data/test/prototype-test.js +13 -0
- data/test/qunit.js +61 -0
- data/test/qunit/qunit/qunit.css +17 -0
- data/test/qunit/qunit/qunit.js +997 -0
- data/test/scope.html +19 -0
- data/test/scope.rb +24 -0
- data/test/smp/dmathieu/index.html +8 -0
- data/test/specs/dist/env.spec.js +1534 -0
- data/test/specs/envjs.spec.css +46 -0
- data/test/specs/parser/html.js +31 -0
- data/test/specs/parser/spec.html +40 -0
- data/test/specs/parser/xml.js +31 -0
- data/test/specs/qunit.bdd.js +210 -0
- data/test/specs/qunit.css +17 -0
- data/test/specs/qunit.js +997 -0
- data/test/specs/template/spec-0.js +31 -0
- data/test/specs/template/spec-1.js +31 -0
- data/test/specs/template/spec.html +40 -0
- data/test/specs/window/css.js +23 -0
- data/test/specs/window/dialog.js +25 -0
- data/test/specs/window/document.js +23 -0
- data/test/specs/window/event.js +25 -0
- data/test/specs/window/history.js +34 -0
- data/test/specs/window/location.js +34 -0
- data/test/specs/window/navigator.js +71 -0
- data/test/specs/window/screen.js +42 -0
- data/test/specs/window/spec.html +48 -0
- data/test/specs/window/timer.js +26 -0
- data/test/specs/window/window.js +53 -0
- data/test/specs/xhr/spec.html +47 -0
- data/test/specs/xhr/xhr.js +31 -0
- data/test/test.js +10 -0
- data/test/unit/dom.js +44 -0
- data/test/unit/elementmembers.js +92 -0
- data/test/unit/events.js +195 -0
- data/test/unit/fixtures/external_script.js +1 -0
- data/test/unit/form.js +40 -0
- data/test/unit/iframe.js +234 -0
- data/test/unit/insertion.js +23 -0
- data/test/unit/multi-window.js +212 -0
- data/test/unit/nu.validator.js +34 -0
- data/test/unit/onload.js +90 -0
- data/test/unit/parser.js +122 -0
- data/test/unit/prototypecompat.js +22 -0
- data/test/unit/proxy.js +6 -0
- data/test/unit/scope.js +209 -0
- data/test/unit/timer.js +115 -0
- data/test/unit/window.js +57 -0
- data/test/x.js +1 -0
- data/test/y.js +1 -0
- metadata +367 -0
@@ -0,0 +1 @@
|
|
1
|
+
var $$$$$ = "12345";
|
data/test/unit/form.js
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module("form");
|
2
|
+
|
3
|
+
test("__param__ without a boundary should do query string style uri encoding", function() {
|
4
|
+
serialized_params = $master.static.__param__([{ name: 'username', value: 'jresig' }, { name: 'password', value: 'letmein' }]);
|
5
|
+
ok((serialized_params == 'username=jresig&password=letmein'), 'params should be key=value and joined by &');
|
6
|
+
});
|
7
|
+
|
8
|
+
test("__param__ without a boundary should escape spaces in values as + not %20", function() {
|
9
|
+
serialized_params = $master.static.__param__([{ name: 'username', value: 'jresig' }, { name: 'password', value: 'let me in' }]);
|
10
|
+
ok((serialized_params == 'username=jresig&password=let+me+in'), 'params should have spaces escaped as + not %20');
|
11
|
+
});
|
12
|
+
|
13
|
+
test("__param__ with a boundary should start with a -- then the boundary and a \\r\\n newline", function() {
|
14
|
+
serialized_params = $master.static.__param__([{ name: 'username', value: 'jresig' }, { name: 'password', value: 'letmein' }], '--aboundary');
|
15
|
+
ok(serialized_params.match(/^----aboundary\r\n/), 'params should start with a -- then the boundary and \\r\\n');
|
16
|
+
});
|
17
|
+
|
18
|
+
test("__param__ with a boundary should end with the boundary then -- and a \\r\\n newline", function() {
|
19
|
+
serialized_params = $master.static.__param__([{ name: 'username', value: 'jresig' }, { name: 'password', value: 'letmein' }], '--aboundary');
|
20
|
+
ok(serialized_params.match(/--aboundary--\r\n$/), 'params should end with the boundary then -- and \\r\\n');
|
21
|
+
});
|
22
|
+
|
23
|
+
test("__param__ with a boundary should render each key and value with a header, two \\r\\n newlines and the value", function() {
|
24
|
+
serialized_params = $master.static.__param__([{ name: 'username', value: 'jresig' }, { name: 'password', value: 'letmein' }], '--aboundary');
|
25
|
+
ok(serialized_params.match(/Content-Disposition: form-data; name="username"\r\n\r\njresig\r\n/), 'username not properly encoded');
|
26
|
+
ok(serialized_params.match(/Content-Disposition: form-data; name="password"\r\n\r\nletmein\r\n/), 'password not properly encoded');
|
27
|
+
});
|
28
|
+
|
29
|
+
test("__param__ with a boundary should separate each key-value with --, the boundary and a \\r\\n newline", function() {
|
30
|
+
serialized_params = $master.static.__param__([{ name: 'username', value: 'jresig' }, { name: 'password', value: 'letmein' }], '--aboundary');
|
31
|
+
ok(serialized_params.match(/jresig\r\n----aboundary\r\nContent-Disposition: form-data; name="password"/), 'username and password not properly separated');
|
32
|
+
});
|
33
|
+
|
34
|
+
test("__param__ with a boundary should not render spaces in data as + or %20", function() {
|
35
|
+
serialized_params = $master.static.__param__([{ name: 'username', value: 'jresig' }, { name: 'password', value: 'let me in' }], '--aboundary');
|
36
|
+
ok(!serialized_params.match(/let+me+in/), 'spaces incorrectly encoded as +');
|
37
|
+
ok(!serialized_params.match(/let%20me%20in/), 'spaces incorrectly encoded as %20');
|
38
|
+
ok(serialized_params.match(/let me in/), 'spaces not left as spaces');
|
39
|
+
});
|
40
|
+
|
data/test/unit/iframe.js
ADDED
@@ -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 = "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
|
+
});
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module("insertion");
|
2
|
+
|
3
|
+
test("inserting SELECT elements with multiple='multiple' should not raise an error", function() {
|
4
|
+
expect(3);
|
5
|
+
var div = document.createElement('div');
|
6
|
+
var html = "<select multiple='multiple'><option value='wheels'>Wheels within Wheels</option></select>";
|
7
|
+
ok(div.innerHTML = html, html);
|
8
|
+
var select = document.createElement('select');
|
9
|
+
var x;
|
10
|
+
try {
|
11
|
+
select.type = "foo";
|
12
|
+
}catch(e){
|
13
|
+
x = e;
|
14
|
+
}
|
15
|
+
ok(x !== void(0), "should not allow setting type");
|
16
|
+
x = void(0);
|
17
|
+
try {
|
18
|
+
select.setAttribute("type","foo");
|
19
|
+
}catch(e){
|
20
|
+
x = e;
|
21
|
+
}
|
22
|
+
ok(x !== void(0), "should not allow setting type via setAttribute");
|
23
|
+
});
|
@@ -0,0 +1,212 @@
|
|
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("multi-window");
|
11
|
+
|
12
|
+
test("2nd window.location= operation flagged as error", function() {
|
13
|
+
expect(1);
|
14
|
+
|
15
|
+
if ( window.Envjs.interpreter === "Johnson" ) {
|
16
|
+
ok(true,"we don't object to setting window.location in Johnson, which will blitz the tests");
|
17
|
+
} else {
|
18
|
+
var gotAnException = false;
|
19
|
+
window.onload = function(){;};
|
20
|
+
try {
|
21
|
+
window.location = "html/trivial.html";
|
22
|
+
} catch (e){ gotAnException = true; }
|
23
|
+
try{ ok(gotAnException, "prohibited window.location setter call fails");
|
24
|
+
}catch(e){print(e);}
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
test("window.open()-related behavior and members", function() {
|
29
|
+
expect(30);
|
30
|
+
|
31
|
+
var anotherWin;
|
32
|
+
try{ ok(anotherWin = window.open("html/trivial.html"),
|
33
|
+
"'window.open' returns new object");
|
34
|
+
}catch(e){print(e);}
|
35
|
+
|
36
|
+
try{ ok(anotherWin.closed == false,
|
37
|
+
"2nd window knows that it is not-closed");
|
38
|
+
}catch(e){print(e);}
|
39
|
+
|
40
|
+
var mtch = anotherWin.document.getElementById('oneP').innerHTML.
|
41
|
+
match(/Nearly-empty HTML/);
|
42
|
+
try{ ok(mtch && mtch.length > 0,
|
43
|
+
"2nd window has correct contents");
|
44
|
+
}catch(e){print(e);}
|
45
|
+
|
46
|
+
try{ ok(anotherWin.opener == window,
|
47
|
+
"2nd window's .opener is original window");
|
48
|
+
}catch(e){print(e);}
|
49
|
+
|
50
|
+
try{ ok(anotherWin.top == anotherWin,
|
51
|
+
"2nd window's .top is itself");
|
52
|
+
}catch(e){print(e);}
|
53
|
+
|
54
|
+
try{ ok(anotherWin.parent == anotherWin,
|
55
|
+
"2nd window's .parent is itself");
|
56
|
+
}catch(e){print(e);}
|
57
|
+
|
58
|
+
try{ ok(anotherWin.document.referrer == location.href,
|
59
|
+
"2nd window's document.referrer points to this one");
|
60
|
+
}catch(e){print(e);}
|
61
|
+
|
62
|
+
|
63
|
+
try{ ok((anotherWin.location = "html/with_js.html") || true,
|
64
|
+
"1st explicit '.location=' completes without exception");
|
65
|
+
}catch(e){print(e);}
|
66
|
+
|
67
|
+
mtch = anotherWin.document.getElementById('HeaderLevel1').
|
68
|
+
innerHTML.match(/Hello/);
|
69
|
+
try{ ok(mtch && mtch.length > 0,
|
70
|
+
"location setter-loaded content is correct");
|
71
|
+
}catch(e){print(e);}
|
72
|
+
|
73
|
+
|
74
|
+
try{ ok((anotherWin.location = "html/trivial.html") || true,
|
75
|
+
"2nd explicit '.location=' completes without exception");
|
76
|
+
}catch(e){print(e);}
|
77
|
+
|
78
|
+
mtch = anotherWin.document.getElementById('oneP').innerHTML.
|
79
|
+
match(/Nearly-empty HTML/);
|
80
|
+
try{ ok(mtch && mtch.length > 0,
|
81
|
+
"2nd location setter-loaded content is correct");
|
82
|
+
}catch(e){print(e);}
|
83
|
+
|
84
|
+
|
85
|
+
var thirdWin;
|
86
|
+
try{ ok(thirdWin = window.open("html/with_js.html"),
|
87
|
+
"2nd 'window.open' returns 3rd window");
|
88
|
+
}catch(e){print(e);}
|
89
|
+
|
90
|
+
mtch = thirdWin.document.getElementById('HeaderLevel1').
|
91
|
+
innerHTML.match(/Hello/);
|
92
|
+
try{ ok(mtch && mtch.length > 0,
|
93
|
+
"3rd window's content is correct");
|
94
|
+
}catch(e){print(e);}
|
95
|
+
|
96
|
+
mtch = anotherWin.document.getElementById('oneP').innerHTML.
|
97
|
+
match(/Nearly-empty HTML/);
|
98
|
+
try{ ok(mtch && mtch.length > 0,
|
99
|
+
"after 3rd window, 2nd's content still correct");
|
100
|
+
}catch(e){print(e);}
|
101
|
+
|
102
|
+
try{ ok(document.title == "jQuery Test Suite",
|
103
|
+
"after 3rd window, original's content still correct");
|
104
|
+
}catch(e){print(e);}
|
105
|
+
|
106
|
+
|
107
|
+
try{ ok(thirdWin.getTestVariables()[0] == "hello, scope",
|
108
|
+
"function from open()'ed window's scope callable");
|
109
|
+
}catch(e){print(e);}
|
110
|
+
|
111
|
+
try{ ok(thirdWin.getTestVariables()[1] == undefined ||
|
112
|
+
thirdWin.getTestVariables()[1] == null,
|
113
|
+
"dynamically-created test variable in 3rd win doesn't exist yet");
|
114
|
+
}catch(e){print(e);}
|
115
|
+
|
116
|
+
try{ ok(thirdWin.setTestVariable(42) || true,
|
117
|
+
"call to fn to create variable in other window's scope w/o exception");
|
118
|
+
}catch(e){print(e);}
|
119
|
+
|
120
|
+
try{ ok(thirdWin.getTestVariables()[1] == 42,
|
121
|
+
"variable in other window's scope created correctly");
|
122
|
+
}catch(e){print(e);}
|
123
|
+
|
124
|
+
try{ ok(thirdWin.notAlwaysPresentVariable == 42,
|
125
|
+
"variable in other window's scope accessible directly, too");
|
126
|
+
}catch(e){print(e);}
|
127
|
+
|
128
|
+
try{ ok((thirdWin.location = "html/with_js.html") || true,
|
129
|
+
"3rd window's '.location=' worked without exception");
|
130
|
+
}catch(e){print(e);}
|
131
|
+
|
132
|
+
try{ ok(thirdWin.getTestVariables()[1] == undefined ||
|
133
|
+
thirdWin.getTestVariables()[1] == null,
|
134
|
+
"reloaded window has clean variable scope");
|
135
|
+
}catch(e){print(e);}
|
136
|
+
|
137
|
+
try{ ok(thirdWin.notAlwaysPresentVariable = 55,
|
138
|
+
"setting variable in other window's scope executes without exception");
|
139
|
+
}catch(e){print(e);}
|
140
|
+
|
141
|
+
try{ ok(thirdWin.getTestVariables()[1] == 55,
|
142
|
+
"directly-set variable visible to code executing in other scope");
|
143
|
+
}catch(e){print(e);}
|
144
|
+
|
145
|
+
try{ ok(window.notAlwaysPresentVariable == undefined ||
|
146
|
+
window.notAlwaysPresentVariable == null,
|
147
|
+
"creating variable in 3rd window scope doesn't affect original window");
|
148
|
+
}catch(e){print(e);}
|
149
|
+
|
150
|
+
try{ ok(anotherWin.notAlwaysPresentVariable == undefined ||
|
151
|
+
anotherWin.notAlwaysPresentVariable == null,
|
152
|
+
"creating variable in 3rd window scope doesn't affect 2nd window");
|
153
|
+
}catch(e){print(e);}
|
154
|
+
|
155
|
+
|
156
|
+
try{ ok(anotherWin.close() || true,
|
157
|
+
"'.close()' executed without exception");
|
158
|
+
}catch(e){print(e);}
|
159
|
+
|
160
|
+
try{ ok(anotherWin.closed == true,
|
161
|
+
"after closing window, '.closed' is true");
|
162
|
+
}catch(e){print(e);}
|
163
|
+
|
164
|
+
try{ ok(window.closed == false,
|
165
|
+
"closing 2nd window doesn't affect original window");
|
166
|
+
}catch(e){print(e);}
|
167
|
+
|
168
|
+
try{ ok(thirdWin.closed == false,
|
169
|
+
"closing 2nd window doesn't affect 3rd window");
|
170
|
+
}catch(e){print(e);}
|
171
|
+
});
|
172
|
+
|
173
|
+
test("window.reload() behavior", function() {
|
174
|
+
expect(3);
|
175
|
+
|
176
|
+
var testWindow = window.open("html/trivial.html");
|
177
|
+
testWindow.checkingScope = 17;
|
178
|
+
try{ ok(testWindow.location.reload() || true,
|
179
|
+
"'window.location.reload()' completes without exception");
|
180
|
+
}catch(e){print(e);}
|
181
|
+
|
182
|
+
var variableNoLongerDefined = false;
|
183
|
+
try {
|
184
|
+
variableNoLongerDefined = (testWindow.checkingScope == undefined);
|
185
|
+
} catch (e){
|
186
|
+
variableNoLongerDefined = true;
|
187
|
+
}
|
188
|
+
try{ ok(variableNoLongerDefined, "reloaded window has clean scope");
|
189
|
+
}catch(e){print(e);}
|
190
|
+
|
191
|
+
var mtch = testWindow.document.getElementById('oneP').innerHTML.
|
192
|
+
match(/Nearly-empty HTML/);
|
193
|
+
try{ ok(mtch && mtch.length > 0,
|
194
|
+
"reloaded window has correct contents");
|
195
|
+
}catch(e){print(e);}
|
196
|
+
});
|
197
|
+
|
198
|
+
test("window.replace() behavior", function() {
|
199
|
+
expect(2);
|
200
|
+
|
201
|
+
var testWindow = window.open("html/trivial.html");
|
202
|
+
try{ ok(testWindow.location.replace("html/with_js.html") || true,
|
203
|
+
"'window.location.replace()' completes without exception");
|
204
|
+
}catch(e){print(e);}
|
205
|
+
|
206
|
+
var mtch = testWindow.document.getElementById('HeaderLevel1').
|
207
|
+
innerHTML.match(/Hello/);
|
208
|
+
try{ ok(mtch && mtch.length > 0, "replaced window has correct content");
|
209
|
+
}catch(e){print(e);}
|
210
|
+
});
|
211
|
+
|
212
|
+
|