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,26 @@
|
|
1
|
+
/**
|
2
|
+
* @author thatcher
|
3
|
+
*/
|
4
|
+
|
5
|
+
(function(Q){
|
6
|
+
|
7
|
+
Q.describe('Window Timer',{
|
8
|
+
|
9
|
+
before:function(){
|
10
|
+
//setup
|
11
|
+
},
|
12
|
+
after:function(){
|
13
|
+
//tear down
|
14
|
+
}
|
15
|
+
|
16
|
+
}).should('provide the required w3c interfaces', function(){
|
17
|
+
|
18
|
+
expect(4);
|
19
|
+
ok(setTimeout, 'setTimeout');
|
20
|
+
ok(setInterval, 'setInterval');
|
21
|
+
ok(clearTimeout, 'clearTimeout');
|
22
|
+
ok(clearInterval, 'clearInterval');
|
23
|
+
|
24
|
+
});
|
25
|
+
|
26
|
+
})(QUnit);
|
@@ -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);
|
data/test/test.js
ADDED
data/test/unit/dom.js
ADDED
@@ -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,92 @@
|
|
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("setting textarea content", function() {
|
7
|
+
expect(2);
|
8
|
+
|
9
|
+
var textarea = document.createElement('textarea');
|
10
|
+
|
11
|
+
try { textarea.value = 'textarea-value';
|
12
|
+
ok(textarea.value == 'textarea-value',
|
13
|
+
"textarea.value= sets the value correctly");
|
14
|
+
}catch(e){print(e);}
|
15
|
+
|
16
|
+
try { textarea.innerText = 'textarea-innerText';
|
17
|
+
ok(textarea.innerText == 'textarea-innerText',
|
18
|
+
"textarea.innerText= sets the value correctly");
|
19
|
+
}catch(e){print(e);}
|
20
|
+
});
|
21
|
+
|
22
|
+
test("getting textarea content", function() {
|
23
|
+
expect(2);
|
24
|
+
|
25
|
+
var textarea = document.createElement('textarea');
|
26
|
+
var text = document.createTextNode('text-area-content');
|
27
|
+
textarea.appendChild(text);
|
28
|
+
|
29
|
+
try { ok(textarea.value == 'text-area-content',
|
30
|
+
"textarea.value returns the correct content, as per http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-24874179");
|
31
|
+
}catch(e){print(e);}
|
32
|
+
|
33
|
+
try { ok(textarea.innerText == 'text-area-content',
|
34
|
+
"textarea.innerText returns the correct content");
|
35
|
+
}catch(e){print(e);}
|
36
|
+
});
|
37
|
+
|
38
|
+
test("attributes common to all HTML elements", function() {
|
39
|
+
expect(4);
|
40
|
+
|
41
|
+
// tests for .innerText
|
42
|
+
var mtch = document.getElementById('dl').innerText.match(
|
43
|
+
/^\s+See this blog entry for more information.\s+Here are/);
|
44
|
+
try{ ok(mtch && mtch.length > 0,
|
45
|
+
"dl.innerText returns the correct content");
|
46
|
+
}catch(e){print(e);}
|
47
|
+
|
48
|
+
mtch = document.getElementById('sndp').innerText.match(/^Everything insid/);
|
49
|
+
try{ ok(mtch && mtch.length > 0,
|
50
|
+
"p.innerText returns the correct content");
|
51
|
+
}catch(e){print(e);}
|
52
|
+
|
53
|
+
try{ ok(document.getElementById('sndp').innerText = "test text" || true,
|
54
|
+
"p.innerText= operates without exception");
|
55
|
+
}catch(e){print(e);}
|
56
|
+
|
57
|
+
try{ ok(document.getElementById('sndp').innerText == "test text",
|
58
|
+
"p.innerText= changes content of element");
|
59
|
+
}catch(e){print(e);}
|
60
|
+
});
|
61
|
+
|
62
|
+
test("select element", function() {
|
63
|
+
expect(14);
|
64
|
+
|
65
|
+
var select = document.getElementById('select1');
|
66
|
+
equals("select-one", select.type, "Select field's type is select-one by default");
|
67
|
+
|
68
|
+
select = document.getElementById('test_value');
|
69
|
+
equals("optionvalue", select.value, "Select field returns its selected option's value as its value");
|
70
|
+
|
71
|
+
// if option2 is selected, unselect option1 (and update select.value)
|
72
|
+
select = document.getElementById('test_selecting');
|
73
|
+
select.options[2].selected = true;
|
74
|
+
ok(select.options[2].selected, "Select's option should be selected");
|
75
|
+
ok(!select.options[1].selected, "Previously selected option should be automatically unselected");
|
76
|
+
equals("2", select.value, "Select's value should be updated");
|
77
|
+
|
78
|
+
// if option2 is unselected, then select first option on the list (and update select.value)
|
79
|
+
select.options[2].selected = false;
|
80
|
+
ok(!select.options[2].selected, "Select's option should be unselected");
|
81
|
+
ok(!select.options[1].selected, "Previously selected option should stay unselected");
|
82
|
+
ok(select.options[0].selected, "First option in the select should be selected");
|
83
|
+
equals("0", select.value, "Select's value should be updated");
|
84
|
+
|
85
|
+
// update select's value and options when selectedIndex is changed
|
86
|
+
equals(0, select.selectedIndex, "Select's selectedIndex should return the index of selected option");
|
87
|
+
select.selectedIndex = 2;
|
88
|
+
equals(2, select.selectedIndex, "Select's selectedIndex should be updated");
|
89
|
+
equals("2", select.value, "Changing selectedIndex should update select's value");
|
90
|
+
ok(!select.options[0].selected, "Changing selectedIndex should unselect currently selected option");
|
91
|
+
ok(select.options[2].selected, "Changing selectedIndex should select option at given index");
|
92
|
+
});
|
data/test/unit/events.js
ADDED
@@ -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
|
+
|