├── .npmrc
├── test
├── w3c
│ ├── level1
│ │ ├── core
│ │ │ ├── files
│ │ │ │ ├── .cvsignore
│ │ │ │ ├── hc_nodtdstaff.html
│ │ │ │ ├── staff.dtd
│ │ │ │ └── hc_staff.html
│ │ │ └── hc_nodeelementnodevalue.js
│ │ └── html
│ │ │ ├── files
│ │ │ ├── .cvsignore
│ │ │ ├── br.html
│ │ │ ├── title.html
│ │ │ ├── base.html
│ │ │ ├── meta.html
│ │ │ ├── paragraph.html
│ │ │ ├── head.html
│ │ │ ├── hr.html
│ │ │ ├── font.html
│ │ │ ├── html.html
│ │ │ ├── style.html
│ │ │ ├── basefont.html
│ │ │ ├── div.html
│ │ │ ├── table1.html
│ │ │ ├── param.html
│ │ │ ├── script.html
│ │ │ ├── menu.html
│ │ │ ├── body.html
│ │ │ ├── anchor2.html
│ │ │ ├── directory.html
│ │ │ ├── dl.html
│ │ │ ├── isindex.html
│ │ │ ├── area.html
│ │ │ ├── area2.html
│ │ │ ├── frameset.html
│ │ │ ├── iframe.html
│ │ │ ├── applet2.html
│ │ │ ├── applet.html
│ │ │ ├── li.html
│ │ │ ├── form3.html
│ │ │ ├── img.html
│ │ │ ├── quote.html
│ │ │ ├── anchor.html
│ │ │ ├── map.html
│ │ │ ├── heading.html
│ │ │ ├── link.html
│ │ │ ├── tablecaption.html
│ │ │ ├── base2.html
│ │ │ ├── frame.html
│ │ │ ├── fieldset.html
│ │ │ ├── link2.html
│ │ │ ├── form.html
│ │ │ ├── mod.html
│ │ │ ├── pre.html
│ │ │ ├── button.html
│ │ │ ├── olist.html
│ │ │ ├── label.html
│ │ │ ├── form2.html
│ │ │ ├── legend.html
│ │ │ ├── optgroup.html
│ │ │ ├── object2.html
│ │ │ ├── object.html
│ │ │ ├── ulist.html
│ │ │ ├── tablecol.html
│ │ │ ├── option.html
│ │ │ ├── tablecell.html
│ │ │ ├── textarea.html
│ │ │ ├── select.html
│ │ │ ├── document.html
│ │ │ ├── HTMLDocument04.html
│ │ │ ├── input.html
│ │ │ ├── tablerow.html
│ │ │ ├── tablesection.html
│ │ │ ├── table.html
│ │ │ └── collection.html
│ │ │ ├── hasFeature01.js
│ │ │ ├── HTMLDocument18.js
│ │ │ ├── doc01.js
│ │ │ ├── nyi
│ │ │ ├── HTMLFormElement10.js
│ │ │ ├── HTMLSelectElement15.js
│ │ │ ├── HTMLFormElement09.js
│ │ │ ├── HTMLInputElement19.js
│ │ │ ├── HTMLInputElement20.js
│ │ │ ├── HTMLSelectElement14.js
│ │ │ ├── HTMLDocument12.js
│ │ │ ├── HTMLTextAreaElement13.js
│ │ │ ├── HTMLTextAreaElement14.js
│ │ │ ├── HTMLTextAreaElement15.js
│ │ │ ├── HTMLInputElement22.js
│ │ │ ├── HTMLDocument02.js
│ │ │ └── HTMLDocument04.js
│ │ │ ├── HTMLAnchorElement13.js
│ │ │ ├── HTMLAnchorElement14.js
│ │ │ ├── area02.js
│ │ │ ├── obsolete
│ │ │ └── dlist01.js
│ │ │ ├── area01.js
│ │ │ ├── area03.js
│ │ │ ├── area04.js
│ │ │ ├── HTMLDocument01.js
│ │ │ ├── HTMLScriptElement07.js
│ │ │ ├── HTMLScriptElement06.js
│ │ │ ├── HTMLLabelElement01.js
│ │ │ ├── object14.js
│ │ │ └── button01.js
│ ├── index.js
│ ├── README.md
│ └── harness
│ │ └── index.js
├── .npmignore
├── index.js
├── fixture
│ └── doc.html
├── parsing.js
└── tools
│ └── update-entities.js
├── .jshintignore
├── .gitignore
├── .mocharc.json
├── lib
├── events.js
├── index.d.ts
├── config.js
├── WindowTimers.js
├── NodeList.es6.js
├── NodeList.es5.js
├── NodeList.js
├── CustomEvent.js
├── MutationConstants.js
├── NavigatorID.js
├── UIEvent.js
├── NodeFilter.js
├── NonDocumentTypeChildNode.js
├── sloppy.js
├── impl.js
├── Comment.js
├── DocumentType.js
├── Leaf.js
├── ProcessingInstruction.js
├── NamedNodeMap.js
├── MouseEvent.js
├── Location.js
├── LinkedList.js
├── Event.js
├── Window.js
├── defineElement.js
├── Text.js
├── DocumentFragment.js
├── svg.js
├── NodeTraversal.js
├── ContainerNode.js
├── index.js
├── FilteredElementList.js
└── DOMImplementation.js
├── .travis.yml
├── .gitmodules
├── tools
├── bump-version.js
└── update-changelog.js
├── .jshintrc
├── package.json
└── LICENSE
/.npmrc:
--------------------------------------------------------------------------------
1 | tag-version-prefix = ""
2 |
--------------------------------------------------------------------------------
/test/w3c/level1/core/files/.cvsignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.jshintignore:
--------------------------------------------------------------------------------
1 | clean
2 | node_modules
3 | test
4 |
--------------------------------------------------------------------------------
/test/.npmignore:
--------------------------------------------------------------------------------
1 | html5lib-tests
2 | web-platform-tests
3 |
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | exports.w3c = require('./w3c');
2 |
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | npm-debug.log
4 | v8.log
5 | .idea
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/.cvsignore:
--------------------------------------------------------------------------------
1 | xhtml1-frameset.dtd
2 | xhtml1-strict.dtd
3 | xhtml1-transitional.dtd
4 | xhtml-lat1.ent
5 | xhtml-special.ent
6 | xhtml-symbol.ent
7 |
--------------------------------------------------------------------------------
/.mocharc.json:
--------------------------------------------------------------------------------
1 | {
2 | "ui": "exports",
3 | "reporter": "dot",
4 | "require": "should",
5 | "slow": 20,
6 | "timeout": 15000,
7 | "check-leaks": true
8 | }
9 |
--------------------------------------------------------------------------------
/lib/events.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = {
3 | Event: require('./Event'),
4 | UIEvent: require('./UIEvent'),
5 | MouseEvent: require('./MouseEvent'),
6 | CustomEvent: require('./CustomEvent')
7 | };
8 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "6"
4 | - "8"
5 | - "10"
6 | # From the nvm docs, "this installs the latest version of node".
7 | - "node"
8 |
9 | script: npm run test-spec
10 | sudo: false
11 |
--------------------------------------------------------------------------------
/lib/index.d.ts:
--------------------------------------------------------------------------------
1 | declare module "domino" {
2 | function createDOMImplementation(): DOMImplementation;
3 | function createDocument(html?: string, force?: boolean): Document;
4 | function createWindow(html?: string, address?: string): Window;
5 | }
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "html5lib-tests"]
2 | path = test/html5lib-tests
3 | url = https://github.com/html5lib/html5lib-tests.git
4 | [submodule "test/web-platform-tests"]
5 | path = test/web-platform-tests
6 | url = https://github.com/w3c/web-platform-tests.git
7 |
--------------------------------------------------------------------------------
/lib/config.js:
--------------------------------------------------------------------------------
1 | /*
2 | * This file defines Domino behaviour that can be externally configured.
3 | * To change these settings, set the relevant global property *before*
4 | * you call `require("domino")`.
5 | */
6 |
7 | exports.isApiWritable = !global.__domino_frozen__;
8 |
--------------------------------------------------------------------------------
/test/w3c/index.js:
--------------------------------------------------------------------------------
1 | var suite = require('./harness');
2 |
3 | exports.level1 = {
4 | core: suite('level1/core/'),
5 | html: suite('level1/html/')
6 | };
7 | /*
8 | exports.level2 = {
9 | core: suite('level2/core/'),
10 | html: suite('level2/html/')
11 | };
12 | */
--------------------------------------------------------------------------------
/lib/WindowTimers.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | // https://html.spec.whatwg.org/multipage/webappapis.html#windowtimers
4 | var WindowTimers = {
5 | setTimeout: setTimeout,
6 | clearTimeout: clearTimeout,
7 | setInterval: setInterval,
8 | clearInterval: clearInterval
9 | };
10 |
11 | module.exports = WindowTimers;
12 |
--------------------------------------------------------------------------------
/lib/NodeList.es6.js:
--------------------------------------------------------------------------------
1 | /* jshint esversion: 6 */
2 | "use strict";
3 |
4 | module.exports = class NodeList extends Array {
5 | constructor(a) {
6 | super((a && a.length) || 0);
7 | if (a) {
8 | for (var idx in a) { this[idx] = a[idx]; }
9 | }
10 | }
11 | item(i) { return this[i] || null; }
12 | };
13 |
--------------------------------------------------------------------------------
/lib/NodeList.es5.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | // No support for subclassing array, return an actual Array object.
4 | function item(i) {
5 | /* jshint validthis: true */
6 | return this[i] || null;
7 | }
8 |
9 | function NodeList(a) {
10 | if (!a) a = [];
11 | a.item = item;
12 | return a;
13 | }
14 |
15 | module.exports = NodeList;
16 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/br.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - BR
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/title.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TITLE
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lib/NodeList.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var NodeList;
4 |
5 | try {
6 | // Attempt to use ES6-style Array subclass if possible.
7 | NodeList = require('./NodeList.es6.js');
8 | } catch (e) {
9 | // No support for subclassing array, return an actual Array object.
10 | NodeList = require('./NodeList.es5.js');
11 | }
12 |
13 | module.exports = NodeList;
14 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - Base
7 |
8 |
9 | Some Text
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/meta.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - META
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lib/CustomEvent.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = CustomEvent;
3 |
4 | var Event = require('./Event');
5 |
6 | function CustomEvent(type, dictionary) {
7 | // Just use the superclass constructor to initialize
8 | Event.call(this, type, dictionary);
9 | }
10 | CustomEvent.prototype = Object.create(Event.prototype, {
11 | constructor: { value: CustomEvent }
12 | });
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/paragraph.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - PARAGRAPH
6 |
7 |
8 |
9 | TEXT
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tools/bump-version.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | var fs = require('fs');
3 | var path = require('path');
4 | var PACKAGEPATH = path.join(__dirname, '..', 'package.json');
5 |
6 | var package = require(PACKAGEPATH);
7 | if (!/\+git$/.test(package.version)) {
8 | package.version += '+git';
9 | fs.writeFileSync(PACKAGEPATH, JSON.stringify(package, null, 2)+'\n', 'utf8');
10 | }
11 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/head.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - HEAD
6 |
7 |
8 | Hello, World.
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/hr.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - HR
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lib/MutationConstants.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = {
3 | VALUE: 1, // The value of a Text, Comment or PI node changed
4 | ATTR: 2, // A new attribute was added or an attribute value and/or prefix changed
5 | REMOVE_ATTR: 3, // An attribute was removed
6 | REMOVE: 4, // A node was removed
7 | MOVE: 5, // A node was moved
8 | INSERT: 6 // A node (or a subtree of nodes) was inserted
9 | };
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/font.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Font
6 |
7 |
8 | Test Tables
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/html.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Html
6 |
7 |
8 | Hello, World.
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/style.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - STYLE
7 |
8 |
9 | Hello, World.
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/basefont.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - BaseFont
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/div.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - DIV
6 |
7 |
8 | The DIV element is a generic block container. This text should be centered.
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/table1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TABLE
6 |
7 |
8 |
9 | HTML can't abide empty table
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/param.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - PARAM
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/script.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - SCRIPT
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/menu.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - MENU
6 |
7 |
8 |
9 | Interview
10 | Paperwork
11 | Give start date
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/body.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Body
6 |
7 |
8 | Hello, World
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/anchor2.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - Anchor
7 |
8 |
9 |
10 | View Submit Button
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/w3c/level1/core/files/hc_nodtdstaff.html:
--------------------------------------------------------------------------------
1 | hc_nodtdstaff
2 |
3 | EMP0001
4 | Margaret Martin
5 | Accountant
6 | 56,000
7 | Female
8 | 1230 North Ave. Dallas, Texas 98551
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/directory.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Directory
6 |
7 |
8 |
9 | DIR item number 1.
10 | DIR item number 2.
11 | DIR item number 3.
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/dl.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - DL
6 |
7 |
8 |
9 | Accountant
10 | 56,000
11 | Female
12 | 1230 North Ave. Dallas, Texas 98551
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/isindex.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - ISINDEX
6 |
7 |
8 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/area.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Area
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/area2.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - Area
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "predef": [ "describe", "specify", "it" ],
3 | "node": true,
4 | "bitwise": true,
5 | "eqeqeq": true,
6 | "freeze": true,
7 | "laxbreak": true,
8 | "laxcomma": true,
9 | "loopfunc": true,
10 | "newcap": false,
11 | "noarg": true,
12 | "node": true,
13 | "nonew": true,
14 | "proto": true,
15 | "strict": true,
16 | "undef": true,
17 | "unused": "vars"
18 | }
19 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/frameset.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - FRAMESET
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/iframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - IFRAME
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/applet2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Applet
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/applet.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Applet
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/li.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - LI
6 |
7 |
8 |
9 | EMP0001
10 |
11 | Margaret Martin
12 |
13 | Accountant
14 | 56,000
15 | Female
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/form3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | FORM3
6 |
7 |
8 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/img.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - IMG
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/quote.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - QUOTE
6 |
7 |
8 |
9 | The Q element is intended for short quotations
10 |
11 |
12 | The BLOCKQUOTE element is used for long quotations.
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/anchor.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Anchor
6 |
7 |
8 |
9 | View Submit Button
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/map.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - MAP
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/lib/NavigatorID.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | // https://html.spec.whatwg.org/multipage/webappapis.html#navigatorid
4 | var NavigatorID = Object.create(null, {
5 | appCodeName: { value: "Mozilla" },
6 | appName: { value: "Netscape" },
7 | appVersion: { value: "4.0" },
8 | platform: { value: "" },
9 | product: { value: "Gecko" },
10 | productSub: { value: "20100101" },
11 | userAgent: { value: "" },
12 | vendor: { value: "" },
13 | vendorSub: { value: "" },
14 | taintEnabled: { value: function() { return false; } }
15 | });
16 |
17 | module.exports = NavigatorID;
18 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/heading.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - HEADING
6 |
7 |
8 | Head Element 1
9 | Head Element 2
10 | Head Element 3
11 | Head Element 4
12 | Head Element 5
13 | Head Element 6
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/link.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - LINK
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/tablecaption.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TABLECAPTION
6 |
7 |
8 |
9 | CAPTION 1
10 |
11 | Employee Id
12 | Employee Name
13 | Position
14 | Salary
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/lib/UIEvent.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Event = require('./Event');
3 |
4 | module.exports = UIEvent;
5 |
6 | function UIEvent() {
7 | // Just use the superclass constructor to initialize
8 | Event.call(this);
9 | this.view = null; // FF uses the current window
10 | this.detail = 0;
11 | }
12 | UIEvent.prototype = Object.create(Event.prototype, {
13 | constructor: { value: UIEvent },
14 | initUIEvent: { value: function(type, bubbles, cancelable, view, detail) {
15 | this.initEvent(type, bubbles, cancelable);
16 | this.view = view;
17 | this.detail = detail;
18 | }}
19 | });
20 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/base2.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 | NIST DOM HTML Test - Base2
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/frame.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - FRAME
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test/w3c/level1/core/files/staff.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
12 |
15 |
17 |
18 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/fieldset.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - FieldSet
6 |
7 |
8 |
9 |
10 | All data entered must be valid
11 |
12 |
13 |
14 |
15 |
16 |
17 | All data entered must be valid
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/link2.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - LINK
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/form.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - FORM
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/mod.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - MOD
6 |
7 |
8 |
9 | The INS element is used to indicate that a section of a document had been inserted.
10 |
11 | The DEL element is used to indicate that a section of a document had been removed.
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/pre.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - PRE
6 |
7 |
8 | The PRE is used to indicate pre-formatted text. Visual agents may:
9 |
10 | leave white space intact.
11 | May render text with a fixed-pitch font.
12 | May disable automatic word wrap.
13 | Must not disable bidirectional processing.
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/button.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - Button
6 |
7 |
8 |
9 |
10 | Reset
11 |
12 |
13 |
14 |
15 |
16 | Extra Button
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/olist.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - OLIST
6 |
7 |
8 |
9 | EMP0001
10 |
11 | Margaret Martin
12 |
13 | Accountant
14 | 56,000
15 |
16 |
17 |
18 |
19 | EMP0002
20 |
21 | Martha Raynolds
22 |
23 | Secretary
24 | 35,000
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/label.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - LABEL
6 |
7 |
8 |
9 |
10 | Enter Your First Password:
11 |
12 |
13 |
14 |
15 | Enter Your Second Password:
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/form2.html:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 | NIST DOM HTML Test - FORM
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/w3c/README.md:
--------------------------------------------------------------------------------
1 | # Document Object Model (DOM) Conformance Test Suites
2 |
3 | http://www.w3.org/DOM/Test/
4 |
5 | Since domino doesn't implement deprecated DOM features some tests are no longer relevant. These tests have been moved to the `obsolete` directory so that they are excluded from the suite.
6 |
7 | ## Attributes vs. Nodes
8 |
9 | The majority of the excluded level1/core tests expect Attributes to inherit from the Node interface which is no longer required in DOM level 4. Also `Element.attributes` no longer returns a NamedNodeMap but a read-only array.
10 |
11 | ## Obsolete Attributes
12 |
13 | Another big hunk of excluded tests checks the support of reflected attributes that have become obsolete in HTML 5.
14 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/legend.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - LEGEND
6 |
7 |
8 |
9 |
10 | Enter Password1:
11 |
12 |
13 |
14 |
15 | Enter Password2:
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/optgroup.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - OPTGROUP
6 |
7 |
8 |
9 |
10 |
11 |
12 | EMP0001
13 | EMP0002
14 | EMP0003A
15 |
16 |
17 | EMP0004
18 | EMP0005
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/object2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - OBJECT
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lib/NodeFilter.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var NodeFilter = {
3 | // Constants for acceptNode()
4 | FILTER_ACCEPT: 1,
5 | FILTER_REJECT: 2,
6 | FILTER_SKIP: 3,
7 |
8 | // Constants for whatToShow
9 | SHOW_ALL: 0xFFFFFFFF,
10 | SHOW_ELEMENT: 0x1,
11 | SHOW_ATTRIBUTE: 0x2, // historical
12 | SHOW_TEXT: 0x4,
13 | SHOW_CDATA_SECTION: 0x8, // historical
14 | SHOW_ENTITY_REFERENCE: 0x10, // historical
15 | SHOW_ENTITY: 0x20, // historical
16 | SHOW_PROCESSING_INSTRUCTION: 0x40,
17 | SHOW_COMMENT: 0x80,
18 | SHOW_DOCUMENT: 0x100,
19 | SHOW_DOCUMENT_TYPE: 0x200,
20 | SHOW_DOCUMENT_FRAGMENT: 0x400,
21 | SHOW_NOTATION: 0x800 // historical
22 | };
23 |
24 | module.exports = (NodeFilter.constructor = NodeFilter.prototype = NodeFilter);
25 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/object.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - OBJECT
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lib/NonDocumentTypeChildNode.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Node = require('./Node');
3 |
4 | var NonDocumentTypeChildNode = {
5 |
6 | nextElementSibling: { get: function() {
7 | if (this.parentNode) {
8 | for (var kid = this.nextSibling; kid !== null; kid = kid.nextSibling) {
9 | if (kid.nodeType === Node.ELEMENT_NODE) return kid;
10 | }
11 | }
12 | return null;
13 | }},
14 |
15 | previousElementSibling: { get: function() {
16 | if (this.parentNode) {
17 | for (var kid = this.previousSibling; kid !== null; kid = kid.previousSibling) {
18 | if (kid.nodeType === Node.ELEMENT_NODE) return kid;
19 | }
20 | }
21 | return null;
22 | }}
23 |
24 | };
25 |
26 | module.exports = NonDocumentTypeChildNode;
27 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/ulist.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - ULIST
6 |
7 |
8 |
9 | EMP0001
10 |
11 | Margaret Martin
12 |
13 | Accountant
14 | 56,000
15 | Female
16 | 1230 North Ave. Dallas, Texas 98551
17 |
18 |
19 |
20 |
21 | EMP0002
22 |
23 | Martha Raynolds
24 |
25 | Secretary
26 | 35,000
27 | Female
28 | 1900 Dallas Road. Dallas, Texas 98554
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/tablecol.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TABLECOL
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | Id
14 | Name
15 | Position
16 | Salary
17 |
18 |
19 | EMP0001
20 | Martin
21 | Accountant
22 | 56,000
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/lib/sloppy.js:
--------------------------------------------------------------------------------
1 | /* Domino uses sloppy-mode features (in particular, `with`) for a few
2 | * minor things. This file encapsulates all the sloppiness; every
3 | * other module should be strict. */
4 | /* jshint strict: false */
5 | /* jshint evil: true */
6 | /* jshint -W085 */
7 | module.exports = {
8 | Window_run: function _run(code, file) {
9 | if (file) code += '\n//@ sourceURL=' + file;
10 | with(this) eval(code);
11 | },
12 | EventHandlerBuilder_build: function build() {
13 | try {
14 | with(this.document.defaultView || Object.create(null))
15 | with(this.document)
16 | with(this.form)
17 | with(this.element)
18 | return eval("(function(event){" + this.body + "})");
19 | }
20 | catch (err) {
21 | return function() { throw err; };
22 | }
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/tools/update-changelog.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/node
2 | var fs = require('fs');
3 | var path = require('path');
4 | var version = require('../package.json').version;
5 |
6 | var CHANGELOG_PATH = path.join(__dirname, '..', 'CHANGELOG.md');
7 |
8 | var changelog = fs.readFileSync(CHANGELOG_PATH, 'utf8');
9 |
10 |
11 | if (/\+git$/.test(version)) {
12 | changelog = '# domino x.x.x (not yet released)\n\n' + changelog;
13 | } else {
14 | changelog = changelog.replace(/^# domino x\.x\.x.*$/m, function() {
15 | var today = new Date();
16 | var fmt = new Intl.DateTimeFormat('en-GB', {
17 | day: 'numeric',
18 | month: 'short',
19 | year: 'numeric',
20 | }).format(today);
21 | return '# domino ' + version + ' (' + fmt + ')';
22 | });
23 | }
24 |
25 | fs.writeFileSync(CHANGELOG_PATH, changelog, 'utf8');
26 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/option.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - OPTION
6 |
7 |
8 |
9 |
10 |
11 | EMP10001
12 | EMP10002
13 | EMP10003
14 | EMP10004
15 | EMP10005
16 |
17 |
18 |
19 |
20 |
21 | EMP20001
22 | EMP20002
23 | EMP20003
24 | EMP20004
25 | EMP20005
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/tablecell.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TABLECELL
6 |
7 |
8 |
9 |
10 |
11 |
12 | Position
13 | Salary
14 |
15 |
16 |
17 |
18 | Accountant
19 | 56,000
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/fixture/doc.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Lore Ipsum
5 |
6 | Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam quis risus eget urna mollis ornare vel eu leo. Donec git ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.
7 |
8 |
9 | Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Etiam porta sem malesuada magna mollis euismod. Duis mollis, est non commodo luctus, nisi erat porttitor ligula , eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla. Donec ullamcorper nulla non metus auctor fringilla.
10 |
11 | Hello World
ignore
Foo, bar
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lib/impl.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var utils = require('./utils');
3 |
4 | exports = module.exports = {
5 | CSSStyleDeclaration: require('./CSSStyleDeclaration'),
6 | CharacterData: require('./CharacterData'),
7 | Comment: require('./Comment'),
8 | DOMException: require('./DOMException'),
9 | DOMImplementation: require('./DOMImplementation'),
10 | DOMTokenList: require('./DOMTokenList'),
11 | Document: require('./Document'),
12 | DocumentFragment: require('./DocumentFragment'),
13 | DocumentType: require('./DocumentType'),
14 | Element: require('./Element'),
15 | HTMLParser: require('./HTMLParser'),
16 | NamedNodeMap: require('./NamedNodeMap'),
17 | Node: require('./Node'),
18 | NodeList: require('./NodeList'),
19 | NodeFilter: require('./NodeFilter'),
20 | ProcessingInstruction: require('./ProcessingInstruction'),
21 | Text: require('./Text'),
22 | Window: require('./Window')
23 | };
24 |
25 | utils.merge(exports, require('./events'));
26 | utils.merge(exports, require('./htmlelts').elements);
27 | utils.merge(exports, require('./svg').elements);
28 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/textarea.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TEXTAREA
6 |
7 |
8 |
9 |
10 | TEXTAREA1
11 |
12 |
13 |
14 |
15 |
16 | TEXTAREA2
17 |
18 |
19 | TEXTAREA3
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lib/Comment.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = Comment;
3 |
4 | var Node = require('./Node');
5 | var CharacterData = require('./CharacterData');
6 |
7 | function Comment(doc, data) {
8 | CharacterData.call(this);
9 | this.nodeType = Node.COMMENT_NODE;
10 | this.ownerDocument = doc;
11 | this._data = data;
12 | }
13 |
14 | var nodeValue = {
15 | get: function() { return this._data; },
16 | set: function(v) {
17 | if (v === null || v === undefined) { v = ''; } else { v = String(v); }
18 | this._data = v;
19 | if (this.rooted)
20 | this.ownerDocument.mutateValue(this);
21 | }
22 | };
23 |
24 | Comment.prototype = Object.create(CharacterData.prototype, {
25 | nodeName: { value: '#comment' },
26 | nodeValue: nodeValue,
27 | textContent: nodeValue,
28 | data: {
29 | get: nodeValue.get,
30 | set: function(v) {
31 | nodeValue.set.call(this, v===null ? '' : String(v));
32 | },
33 | },
34 |
35 | // Utility methods
36 | clone: { value: function clone() {
37 | return new Comment(this.ownerDocument, this._data);
38 | }},
39 | });
40 |
--------------------------------------------------------------------------------
/lib/DocumentType.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = DocumentType;
3 |
4 | var Node = require('./Node');
5 | var Leaf = require('./Leaf');
6 | var ChildNode = require('./ChildNode');
7 |
8 | function DocumentType(ownerDocument, name, publicId, systemId) {
9 | Leaf.call(this);
10 | this.nodeType = Node.DOCUMENT_TYPE_NODE;
11 | this.ownerDocument = ownerDocument || null;
12 | this.name = name;
13 | this.publicId = publicId || "";
14 | this.systemId = systemId || "";
15 | }
16 |
17 | DocumentType.prototype = Object.create(Leaf.prototype, {
18 | nodeName: { get: function() { return this.name; }},
19 | nodeValue: {
20 | get: function() { return null; },
21 | set: function() {}
22 | },
23 |
24 | // Utility methods
25 | clone: { value: function clone() {
26 | return new DocumentType(this.ownerDocument, this.name, this.publicId, this.systemId);
27 | }},
28 |
29 | isEqual: { value: function isEqual(n) {
30 | return this.name === n.name &&
31 | this.publicId === n.publicId &&
32 | this.systemId === n.systemId;
33 | }}
34 | });
35 |
36 | Object.defineProperties(DocumentType.prototype, ChildNode);
37 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/select.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - SELECT
6 |
7 |
8 |
9 |
10 |
11 | EMP10001
12 | EMP10002
13 | EMP10003
14 | EMP10004
15 | EMP10005
16 |
17 |
18 |
19 |
20 |
21 | EMP20001
22 | EMP20002
23 | EMP20003
24 | EMP20004
25 | EMP20005
26 |
27 |
28 |
29 |
30 | EMP30001
31 | EMP30002
32 | EMP30003
33 | EMP30004
34 | EMP30005
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/lib/Leaf.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = Leaf;
3 |
4 | var Node = require('./Node');
5 | var NodeList = require('./NodeList');
6 | var utils = require('./utils');
7 | var HierarchyRequestError = utils.HierarchyRequestError;
8 | var NotFoundError = utils.NotFoundError;
9 |
10 | // This class defines common functionality for node subtypes that
11 | // can never have children
12 | function Leaf() {
13 | Node.call(this);
14 | }
15 |
16 | Leaf.prototype = Object.create(Node.prototype, {
17 | hasChildNodes: { value: function() { return false; }},
18 | firstChild: { value: null },
19 | lastChild: { value: null },
20 | insertBefore: { value: function(node, child) {
21 | if (!node.nodeType) throw new TypeError('not a node');
22 | HierarchyRequestError();
23 | }},
24 | replaceChild: { value: function(node, child) {
25 | if (!node.nodeType) throw new TypeError('not a node');
26 | HierarchyRequestError();
27 | }},
28 | removeChild: { value: function(node) {
29 | if (!node.nodeType) throw new TypeError('not a node');
30 | NotFoundError();
31 | }},
32 | removeChildren: { value: function() { /* no op */ }},
33 | childNodes: { get: function() {
34 | if (!this._childNodes) this._childNodes = new NodeList();
35 | return this._childNodes;
36 | }}
37 | });
38 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "domino",
3 | "version": "2.1.6+git",
4 | "license": "BSD-2-Clause",
5 | "author": "Felix Gnass ",
6 | "description": "Server-side DOM implementation based on Mozilla's dom.js",
7 | "homepage": "https://github.com/fgnass/domino",
8 | "main": "./lib",
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/fgnass/domino.git"
12 | },
13 | "files": [
14 | "CHANGELOG.md",
15 | "LICENSE",
16 | "README.md",
17 | "lib"
18 | ],
19 | "scripts": {
20 | "lint": "jshint lib test/*.js",
21 | "mocha": "./node_modules/.bin/mocha",
22 | "mocha-spec": "./node_modules/.bin/mocha -R spec",
23 | "test": "npm run lint && npm run mocha",
24 | "test-spec": "npm run lint && npm run mocha-spec",
25 | "regen-html5lib-tests": "node test/tools/update-html5lib-tests.js test/html5lib-tests.json",
26 | "bump-version": "npm version patch -m 'Release domino %s.' && tools/bump-version.js && npm run version && git add package.json && git commit -m 'Bump version after release.'",
27 | "version": "tools/update-changelog.js && git add CHANGELOG.md"
28 | },
29 | "types": "lib/index.d.ts",
30 | "devDependencies": {
31 | "jquery": "^3.5.1",
32 | "jshint": "^2.11.1",
33 | "mocha": "^6.2.3",
34 | "should": "^13.2.3"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/lib/ProcessingInstruction.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = ProcessingInstruction;
3 |
4 | var Node = require('./Node');
5 | var CharacterData = require('./CharacterData');
6 |
7 | function ProcessingInstruction(doc, target, data) {
8 | CharacterData.call(this);
9 | this.nodeType = Node.PROCESSING_INSTRUCTION_NODE;
10 | this.ownerDocument = doc;
11 | this.target = target;
12 | this._data = data;
13 | }
14 |
15 | var nodeValue = {
16 | get: function() { return this._data; },
17 | set: function(v) {
18 | if (v === null || v === undefined) { v = ''; } else { v = String(v); }
19 | this._data = v;
20 | if (this.rooted) this.ownerDocument.mutateValue(this);
21 | }
22 | };
23 |
24 | ProcessingInstruction.prototype = Object.create(CharacterData.prototype, {
25 | nodeName: { get: function() { return this.target; }},
26 | nodeValue: nodeValue,
27 | textContent: nodeValue,
28 | data: {
29 | get: nodeValue.get,
30 | set: function(v) {
31 | nodeValue.set.call(this, v===null ? '' : String(v));
32 | },
33 | },
34 |
35 | // Utility methods
36 | clone: { value: function clone() {
37 | return new ProcessingInstruction(this.ownerDocument, this.target, this._data);
38 | }},
39 | isEqual: { value: function isEqual(n) {
40 | return this.target === n.target && this._data === n._data;
41 | }}
42 |
43 | });
44 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2011 The Mozilla Foundation.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 |
11 | Redistributions in binary form must reproduce the above copyright
12 | notice, this list of conditions and the following disclaimer in the
13 | documentation and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
18 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
21 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/lib/NamedNodeMap.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = NamedNodeMap;
3 |
4 | var utils = require('./utils');
5 |
6 | /* This is a hacky implementation of NamedNodeMap, intended primarily to
7 | * satisfy clients (like dompurify and the web-platform-tests) which check
8 | * to ensure that Node#attributes instanceof NamedNodeMap. */
9 |
10 | function NamedNodeMap(element) {
11 | this.element = element;
12 | }
13 | Object.defineProperties(NamedNodeMap.prototype, {
14 | length: { get: utils.shouldOverride },
15 | item: { value: utils.shouldOverride },
16 |
17 | getNamedItem: { value: function getNamedItem(qualifiedName) {
18 | return this.element.getAttributeNode(qualifiedName);
19 | } },
20 | getNamedItemNS: { value: function getNamedItemNS(namespace, localName) {
21 | return this.element.getAttributeNodeNS(namespace, localName);
22 | } },
23 | setNamedItem: { value: utils.nyi },
24 | setNamedItemNS: { value: utils.nyi },
25 | removeNamedItem: { value: function removeNamedItem(qualifiedName) {
26 | var attr = this.element.getAttributeNode(qualifiedName);
27 | if (attr) {
28 | this.element.removeAttribute(qualifiedName);
29 | return attr;
30 | }
31 | utils.NotFoundError();
32 | } },
33 | removeNamedItemNS: { value: function removeNamedItemNS(ns, lname) {
34 | var attr = this.element.getAttributeNodeNS(ns, lname);
35 | if (attr) {
36 | this.element.removeAttributeNS(ns, lname);
37 | return attr;
38 | }
39 | utils.NotFoundError();
40 | } },
41 | });
42 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/document.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - DOCUMENT
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | View Submit Button
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/lib/MouseEvent.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var UIEvent = require('./UIEvent');
3 |
4 | module.exports = MouseEvent;
5 |
6 | function MouseEvent() {
7 | // Just use the superclass constructor to initialize
8 | UIEvent.call(this);
9 |
10 | this.screenX = this.screenY = this.clientX = this.clientY = 0;
11 | this.ctrlKey = this.altKey = this.shiftKey = this.metaKey = false;
12 | this.button = 0;
13 | this.buttons = 1;
14 | this.relatedTarget = null;
15 | }
16 | MouseEvent.prototype = Object.create(UIEvent.prototype, {
17 | constructor: { value: MouseEvent },
18 | initMouseEvent: { value: function(type, bubbles, cancelable,
19 | view, detail,
20 | screenX, screenY, clientX, clientY,
21 | ctrlKey, altKey, shiftKey, metaKey,
22 | button, relatedTarget) {
23 |
24 | this.initEvent(type, bubbles, cancelable, view, detail);
25 | this.screenX = screenX;
26 | this.screenY = screenY;
27 | this.clientX = clientX;
28 | this.clientY = clientY;
29 | this.ctrlKey = ctrlKey;
30 | this.altKey = altKey;
31 | this.shiftKey = shiftKey;
32 | this.metaKey = metaKey;
33 | this.button = button;
34 | switch(button) {
35 | case 0: this.buttons = 1; break;
36 | case 1: this.buttons = 4; break;
37 | case 2: this.buttons = 2; break;
38 | default: this.buttons = 0; break;
39 | }
40 | this.relatedTarget = relatedTarget;
41 | }},
42 |
43 | getModifierState: { value: function(key) {
44 | switch(key) {
45 | case "Alt": return this.altKey;
46 | case "Control": return this.ctrlKey;
47 | case "Shift": return this.shiftKey;
48 | case "Meta": return this.metaKey;
49 | default: return false;
50 | }
51 | }}
52 | });
53 |
--------------------------------------------------------------------------------
/lib/Location.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var URL = require('./URL');
3 | var URLUtils = require('./URLUtils');
4 |
5 | module.exports = Location;
6 |
7 | function Location(window, href) {
8 | this._window = window;
9 | this._href = href;
10 | }
11 |
12 | Location.prototype = Object.create(URLUtils.prototype, {
13 | constructor: { value: Location },
14 |
15 | // Special behavior when href is set
16 | href: {
17 | get: function() { return this._href; },
18 | set: function(v) { this.assign(v); }
19 | },
20 |
21 | assign: { value: function(url) {
22 | // Resolve the new url against the current one
23 | // XXX:
24 | // This is not actually correct. It should be resolved against
25 | // the URL of the document of the script. For now, though, I only
26 | // support a single window and there is only one base url.
27 | // So this is good enough for now.
28 | var current = new URL(this._href);
29 | var newurl = current.resolve(url);
30 |
31 | // Save the new url
32 | this._href = newurl;
33 |
34 | // Start loading the new document!
35 | // XXX
36 | // This is just something hacked together.
37 | // The real algorithm is: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#navigate
38 | }},
39 |
40 | replace: { value: function(url) {
41 | // XXX
42 | // Since we aren't tracking history yet, replace is the same as assign
43 | this.assign(url);
44 | }},
45 |
46 | reload: { value: function() {
47 | // XXX:
48 | // Actually, the spec is a lot more complicated than this
49 | this.assign(this.href);
50 | }},
51 |
52 | toString: { value: function() {
53 | return this.href;
54 | }}
55 |
56 | });
57 |
--------------------------------------------------------------------------------
/lib/LinkedList.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var utils = require('./utils');
3 |
4 | var LinkedList = module.exports = {
5 | // basic validity tests on a circular linked list a
6 | valid: function(a) {
7 | utils.assert(a, "list falsy");
8 | utils.assert(a._previousSibling, "previous falsy");
9 | utils.assert(a._nextSibling, "next falsy");
10 | // xxx check that list is actually circular
11 | return true;
12 | },
13 | // insert a before b
14 | insertBefore: function(a, b) {
15 | utils.assert(LinkedList.valid(a) && LinkedList.valid(b));
16 | var a_first = a, a_last = a._previousSibling;
17 | var b_first = b, b_last = b._previousSibling;
18 | a_first._previousSibling = b_last;
19 | a_last._nextSibling = b_first;
20 | b_last._nextSibling = a_first;
21 | b_first._previousSibling = a_last;
22 | utils.assert(LinkedList.valid(a) && LinkedList.valid(b));
23 | },
24 | // replace a single node a with a list b (which could be null)
25 | replace: function(a, b) {
26 | utils.assert(LinkedList.valid(a) && (b===null || LinkedList.valid(b)));
27 | if (b!==null) {
28 | LinkedList.insertBefore(b, a);
29 | }
30 | LinkedList.remove(a);
31 | utils.assert(LinkedList.valid(a) && (b===null || LinkedList.valid(b)));
32 | },
33 | // remove single node a from its list
34 | remove: function(a) {
35 | utils.assert(LinkedList.valid(a));
36 | var prev = a._previousSibling;
37 | if (prev === a) { return; }
38 | var next = a._nextSibling;
39 | prev._nextSibling = next;
40 | next._previousSibling = prev;
41 | a._previousSibling = a._nextSibling = a;
42 | utils.assert(LinkedList.valid(a));
43 | }
44 | };
45 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/HTMLDocument04.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - DOCUMENT
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | View Submit Button
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/test/w3c/level1/core/files/hc_staff.html:
--------------------------------------------------------------------------------
1 |
3 |
4 | hc_staff
5 |
6 | EMP0001
7 | Margaret Martin
8 | Accountant
9 | 56,000
10 | Female
11 | 1230 North Ave. Dallas, Texas 98551
12 |
13 |
14 | EMP0002
15 | Martha RaynoldsThis is a CDATASection with EntityReference number 2 &ent2;
16 | This is an adjacent CDATASection with a reference to a tab &tab;
17 | Secretary
18 | 35,000
19 | Female
20 | β Dallas, γ
21 | 98554
22 |
23 |
24 | EMP0003
25 | Roger
26 | Jones
27 | Department Manager
28 | 100,000
29 | δ
30 | PO Box 27 Irving, texas 98553
31 |
32 |
33 | EMP0004
34 | Jeny Oconnor
35 | Personnel Director
36 | 95,000
37 | Female
38 | 27 South Road. Dallas, Texas 98556
39 |
40 |
41 | EMP0005
42 | Robert Myers
43 | Computer Specialist
44 | 90,000
45 | male
46 | 1821 Nordic. Road, Irving Texas 98558
47 |
48 |
49 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/input.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - INPUT
6 |
7 |
8 |
9 |
10 | Under a FORM control
11 |
12 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/lib/Event.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = Event;
3 |
4 | Event.CAPTURING_PHASE = 1;
5 | Event.AT_TARGET = 2;
6 | Event.BUBBLING_PHASE = 3;
7 |
8 | function Event(type, dictionary) {
9 | // Initialize basic event properties
10 | this.type = '';
11 | this.target = null;
12 | this.currentTarget = null;
13 | this.eventPhase = Event.AT_TARGET;
14 | this.bubbles = false;
15 | this.cancelable = false;
16 | this.isTrusted = false;
17 | this.defaultPrevented = false;
18 | this.timeStamp = Date.now();
19 |
20 | // Initialize internal flags
21 | // XXX: Would it be better to inherit these defaults from the prototype?
22 | this._propagationStopped = false;
23 | this._immediatePropagationStopped = false;
24 | this._initialized = true;
25 | this._dispatching = false;
26 |
27 | // Now initialize based on the constructor arguments (if any)
28 | if (type) this.type = type;
29 | if (dictionary) {
30 | for(var p in dictionary) {
31 | this[p] = dictionary[p];
32 | }
33 | }
34 | }
35 |
36 | Event.prototype = Object.create(Object.prototype, {
37 | constructor: { value: Event },
38 | stopPropagation: { value: function stopPropagation() {
39 | this._propagationStopped = true;
40 | }},
41 |
42 | stopImmediatePropagation: { value: function stopImmediatePropagation() {
43 | this._propagationStopped = true;
44 | this._immediatePropagationStopped = true;
45 | }},
46 |
47 | preventDefault: { value: function preventDefault() {
48 | if (this.cancelable) this.defaultPrevented = true;
49 | }},
50 |
51 | initEvent: { value: function initEvent(type, bubbles, cancelable) {
52 | this._initialized = true;
53 | if (this._dispatching) return;
54 |
55 | this._propagationStopped = false;
56 | this._immediatePropagationStopped = false;
57 | this.defaultPrevented = false;
58 | this.isTrusted = false;
59 |
60 | this.target = null;
61 | this.type = type;
62 | this.bubbles = bubbles;
63 | this.cancelable = cancelable;
64 | }},
65 |
66 | });
67 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/tablerow.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TABLEROW
6 |
7 |
8 |
9 |
10 | Id
11 | Name
12 | Position
13 | Salary
14 |
15 |
16 |
17 | Table Caption
18 |
19 |
20 |
21 |
22 | Position
23 | Salary
24 | Gender
25 | Address
26 |
27 |
28 |
29 |
30 | next page ...
31 | next page ...
32 | next page ...
33 | next page ...
34 | next page ...
35 | next page ...
36 |
37 |
38 |
39 |
40 | EMP0001
41 | Margaret Martin
42 | Accountant
43 | 56,000
44 | Female
45 | 1230 North Ave. Dallas, Texas 98551
46 |
47 |
48 | EMP0002
49 | Martha Raynolds
50 | Secretary
51 | 35,000
52 | Female
53 | 1900 Dallas Road Dallas, Texas 98554
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/lib/Window.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var DOMImplementation = require('./DOMImplementation');
3 | var EventTarget = require('./EventTarget');
4 | var Location = require('./Location');
5 | var sloppy = require('./sloppy');
6 | var utils = require('./utils');
7 |
8 | module.exports = Window;
9 |
10 | function Window(document) {
11 | this.document = document || new DOMImplementation(null).createHTMLDocument("");
12 | this.document._scripting_enabled = true;
13 | this.document.defaultView = this;
14 | this.location = new Location(this, this.document._address || 'about:blank');
15 | }
16 |
17 | Window.prototype = Object.create(EventTarget.prototype, {
18 | _run: { value: sloppy.Window_run },
19 | console: { value: console },
20 | history: { value: {
21 | back: utils.nyi,
22 | forward: utils.nyi,
23 | go: utils.nyi
24 | }},
25 | navigator: { value: require("./NavigatorID") },
26 |
27 | // Self-referential properties
28 | window: { get: function() { return this; }},
29 | self: { get: function() { return this; }},
30 | frames: { get: function() { return this; }},
31 |
32 | // Self-referential properties for a top-level window
33 | parent: { get: function() { return this; }},
34 | top: { get: function() { return this; }},
35 |
36 | // We don't support any other windows for now
37 | length: { value: 0 }, // no frames
38 | frameElement: { value: null }, // not part of a frame
39 | opener: { value: null }, // not opened by another window
40 |
41 | // The onload event handler.
42 | // XXX: need to support a bunch of other event types, too,
43 | // and have them interoperate with document.body.
44 |
45 | onload: {
46 | get: function() {
47 | return this._getEventHandler("load");
48 | },
49 | set: function(v) {
50 | this._setEventHandler("load", v);
51 | }
52 | },
53 |
54 | // XXX This is a completely broken implementation
55 | getComputedStyle: { value: function getComputedStyle(elt) {
56 | return elt.style;
57 | }}
58 |
59 | });
60 |
61 | utils.expose(require('./WindowTimers'), Window);
62 | utils.expose(require('./impl'), Window);
63 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/tablesection.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TABLESECTION
6 |
7 |
8 |
9 |
10 |
11 | Id
12 | Name
13 | Position
14 | Salary
15 |
16 |
17 |
18 |
19 | Table Caption
20 |
21 |
22 |
23 |
24 | Position
25 | Salary
26 | Gender
27 | Address
28 |
29 |
30 |
31 |
32 | next page ...
33 | next page ...
34 | next page ...
35 | next page ...
36 | next page ...
37 | next page ...
38 |
39 |
40 |
41 |
42 | EMP0001
43 | Margaret Martin
44 | Accountant
45 | 56,000
46 | Female
47 | 1230 North Ave. Dallas, Texas 98551
48 |
49 |
50 | EMP0002
51 | Martha Raynolds
52 | Secretary
53 | 35,000
54 | Female
55 | 1900 Dallas Road Dallas, Texas 98554
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/table.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - TABLE
6 |
7 |
8 |
9 |
10 | Id
11 | Name
12 | Position
13 | Salary
14 |
15 |
16 |
17 | Table Caption
18 |
19 |
20 |
21 |
22 | Position
23 | Salary
24 | Gender
25 | Address
26 |
27 |
28 |
29 |
30 | next page ...
31 | next page ...
32 | next page ...
33 | next page ...
34 | next page ...
35 | next page ...
36 |
37 |
38 |
39 |
40 | EMP0001
41 | Margaret Martin
42 | Accountant
43 | 56,000
44 | Female
45 | 1230 North Ave. Dallas, Texas 98551
46 |
47 |
48 | EMP0002
49 | Martha Raynolds
50 | Secretary
51 | 35,000
52 | Female
53 | 1900 Dallas Road Dallas, Texas 98554
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/lib/defineElement.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var attributes = require('./attributes');
4 | var sloppy = require('./sloppy');
5 | var isApiWritable = require("./config").isApiWritable;
6 |
7 | module.exports = function(spec, defaultConstructor, tagList, tagNameToImpl) {
8 | var c = spec.ctor;
9 | if (c) {
10 | var props = spec.props || {};
11 |
12 | if (spec.attributes) {
13 | for (var n in spec.attributes) {
14 | var attr = spec.attributes[n];
15 | if (typeof attr !== 'object' || Array.isArray(attr)) attr = {type: attr};
16 | if (!attr.name) attr.name = n.toLowerCase();
17 | props[n] = attributes.property(attr);
18 | }
19 | }
20 |
21 | props.constructor = { value : c, writable: isApiWritable };
22 | c.prototype = Object.create((spec.superclass || defaultConstructor).prototype, props);
23 | if (spec.events) {
24 | addEventHandlers(c, spec.events);
25 | }
26 | tagList[c.name] = c;
27 | }
28 | else {
29 | c = defaultConstructor;
30 | }
31 |
32 | (spec.tags || spec.tag && [spec.tag] || []).forEach(function(tag) {
33 | tagNameToImpl[tag] = c;
34 | });
35 |
36 | return c;
37 | };
38 |
39 | function EventHandlerBuilder(body, document, form, element) {
40 | this.body = body;
41 | this.document = document;
42 | this.form = form;
43 | this.element = element;
44 | }
45 |
46 | EventHandlerBuilder.prototype.build = sloppy.EventHandlerBuilder_build;
47 |
48 | function EventHandlerChangeHandler(elt, name, oldval, newval) {
49 | var doc = elt.ownerDocument || Object.create(null);
50 | var form = elt.form || Object.create(null);
51 | elt[name] = new EventHandlerBuilder(newval, doc, form, elt).build();
52 | }
53 |
54 | function addEventHandlers(c, eventHandlerTypes) {
55 | var p = c.prototype;
56 | eventHandlerTypes.forEach(function(type) {
57 | // Define the event handler registration IDL attribute for this type
58 | Object.defineProperty(p, "on" + type, {
59 | get: function() {
60 | return this._getEventHandler(type);
61 | },
62 | set: function(v) {
63 | this._setEventHandler(type, v);
64 | },
65 | });
66 |
67 | // Define special behavior for the content attribute as well
68 | attributes.registerChangeHandler(c, "on" + type, EventHandlerChangeHandler);
69 | });
70 | }
71 |
--------------------------------------------------------------------------------
/lib/Text.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = Text;
3 |
4 | var utils = require('./utils');
5 | var Node = require('./Node');
6 | var CharacterData = require('./CharacterData');
7 |
8 | function Text(doc, data) {
9 | CharacterData.call(this);
10 | this.nodeType = Node.TEXT_NODE;
11 | this.ownerDocument = doc;
12 | this._data = data;
13 | this._index = undefined;
14 | }
15 |
16 | var nodeValue = {
17 | get: function() { return this._data; },
18 | set: function(v) {
19 | if (v === null || v === undefined) { v = ''; } else { v = String(v); }
20 | if (v === this._data) return;
21 | this._data = v;
22 | if (this.rooted)
23 | this.ownerDocument.mutateValue(this);
24 | if (this.parentNode &&
25 | this.parentNode._textchangehook)
26 | this.parentNode._textchangehook(this);
27 | }
28 | };
29 |
30 | Text.prototype = Object.create(CharacterData.prototype, {
31 | nodeName: { value: "#text" },
32 | // These three attributes are all the same.
33 | // The data attribute has a [TreatNullAs=EmptyString] but we'll
34 | // implement that at the interface level
35 | nodeValue: nodeValue,
36 | textContent: nodeValue,
37 | data: {
38 | get: nodeValue.get,
39 | set: function(v) {
40 | nodeValue.set.call(this, v===null ? '' : String(v));
41 | },
42 | },
43 |
44 | splitText: { value: function splitText(offset) {
45 | if (offset > this._data.length || offset < 0) utils.IndexSizeError();
46 |
47 | var newdata = this._data.substring(offset),
48 | newnode = this.ownerDocument.createTextNode(newdata);
49 | this.data = this.data.substring(0, offset);
50 |
51 | var parent = this.parentNode;
52 | if (parent !== null)
53 | parent.insertBefore(newnode, this.nextSibling);
54 |
55 | return newnode;
56 | }},
57 |
58 | wholeText: { get: function wholeText() {
59 | var result = this.textContent;
60 | for (var next = this.nextSibling; next; next = next.nextSibling) {
61 | if (next.nodeType !== Node.TEXT_NODE) { break; }
62 | result += next.textContent;
63 | }
64 | return result;
65 | }},
66 | // Obsolete, removed from spec.
67 | replaceWholeText: { value: utils.nyi },
68 |
69 | // Utility methods
70 | clone: { value: function clone() {
71 | return new Text(this.ownerDocument, this._data);
72 | }},
73 |
74 | });
75 |
--------------------------------------------------------------------------------
/lib/DocumentFragment.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = DocumentFragment;
3 |
4 | var Node = require('./Node');
5 | var NodeList = require('./NodeList');
6 | var ContainerNode = require('./ContainerNode');
7 | var Element = require('./Element');
8 | var select = require('./select');
9 | var utils = require('./utils');
10 |
11 | function DocumentFragment(doc) {
12 | ContainerNode.call(this);
13 | this.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
14 | this.ownerDocument = doc;
15 | }
16 |
17 | DocumentFragment.prototype = Object.create(ContainerNode.prototype, {
18 | nodeName: { value: '#document-fragment' },
19 | nodeValue: {
20 | get: function() {
21 | return null;
22 | },
23 | set: function() {}
24 | },
25 | // Copy the text content getter/setter from Element
26 | textContent: Object.getOwnPropertyDescriptor(Element.prototype, 'textContent'),
27 |
28 | querySelector: { value: function(selector) {
29 | // implement in terms of querySelectorAll
30 | var nodes = this.querySelectorAll(selector);
31 | return nodes.length ? nodes[0] : null;
32 | }},
33 | querySelectorAll: { value: function(selector) {
34 | // create a context
35 | var context = Object.create(this);
36 | // add some methods to the context for zest implementation, without
37 | // adding them to the public DocumentFragment API
38 | context.isHTML = true; // in HTML namespace (case-insensitive match)
39 | context.getElementsByTagName = Element.prototype.getElementsByTagName;
40 | context.nextElement =
41 | Object.getOwnPropertyDescriptor(Element.prototype, 'firstElementChild').
42 | get;
43 | // invoke zest
44 | var nodes = select(selector, context);
45 | return nodes.item ? nodes : new NodeList(nodes);
46 | }},
47 |
48 | // Utility methods
49 | clone: { value: function clone() {
50 | return new DocumentFragment(this.ownerDocument);
51 | }},
52 | isEqual: { value: function isEqual(n) {
53 | // Any two document fragments are shallowly equal.
54 | // Node.isEqualNode() will test their children for equality
55 | return true;
56 | }},
57 |
58 | // Non-standard, but useful (github issue #73)
59 | innerHTML: {
60 | get: function() { return this.serialize(); },
61 | set: utils.nyi
62 | },
63 | outerHTML: {
64 | get: function() { return this.serialize(); },
65 | set: utils.nyi
66 | },
67 |
68 | });
69 |
--------------------------------------------------------------------------------
/lib/svg.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var Element = require('./Element');
3 | var defineElement = require('./defineElement');
4 | var utils = require('./utils');
5 | var CSSStyleDeclaration = require('./CSSStyleDeclaration');
6 |
7 | var svgElements = exports.elements = {};
8 | var svgNameToImpl = Object.create(null);
9 |
10 | exports.createElement = function(doc, localName, prefix) {
11 | var impl = svgNameToImpl[localName] || SVGElement;
12 | return new impl(doc, localName, prefix);
13 | };
14 |
15 | function define(spec) {
16 | return defineElement(spec, SVGElement, svgElements, svgNameToImpl);
17 | }
18 |
19 | var SVGElement = define({
20 | superclass: Element,
21 | ctor: function SVGElement(doc, localName, prefix) {
22 | Element.call(this, doc, localName, utils.NAMESPACE.SVG, prefix);
23 | },
24 | props: {
25 | style: { get: function() {
26 | if (!this._style)
27 | this._style = new CSSStyleDeclaration(this);
28 | return this._style;
29 | }}
30 | }
31 | });
32 |
33 | define({
34 | ctor: function SVGSVGElement(doc, localName, prefix) {
35 | SVGElement.call(this, doc, localName, prefix);
36 | },
37 | tag: 'svg',
38 | props: {
39 | createSVGRect: { value: function () {
40 | return exports.createElement(this.ownerDocument, 'rect', null);
41 | } }
42 | }
43 | });
44 |
45 | define({
46 | tags: [
47 | 'a', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 'animateMotion', 'animateTransform',
48 | 'circle', 'clipPath', 'color-profile', 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix',
49 | 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight',
50 | 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode',
51 | 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter',
52 | 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignObject', 'g',
53 | 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph',
54 | 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'script', 'set', 'stop', 'style',
55 | 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 'tspan', 'use', 'view', 'vkern'
56 | ]
57 | });
58 |
--------------------------------------------------------------------------------
/lib/NodeTraversal.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | /* exported NodeTraversal */
3 | var NodeTraversal = module.exports = {
4 | nextSkippingChildren: nextSkippingChildren,
5 | nextAncestorSibling: nextAncestorSibling,
6 | next: next,
7 | previous: previous,
8 | deepLastChild: deepLastChild
9 | };
10 |
11 | /**
12 | * @based on WebKit's NodeTraversal::nextSkippingChildren
13 | * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L109
14 | */
15 | function nextSkippingChildren(node, stayWithin) {
16 | if (node === stayWithin) {
17 | return null;
18 | }
19 | if (node.nextSibling !== null) {
20 | return node.nextSibling;
21 | }
22 | return nextAncestorSibling(node, stayWithin);
23 | }
24 |
25 | /**
26 | * @based on WebKit's NodeTraversal::nextAncestorSibling
27 | * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.cpp?rev=179143#L93
28 | */
29 | function nextAncestorSibling(node, stayWithin) {
30 | for (node = node.parentNode; node !== null; node = node.parentNode) {
31 | if (node === stayWithin) {
32 | return null;
33 | }
34 | if (node.nextSibling !== null) {
35 | return node.nextSibling;
36 | }
37 | }
38 | return null;
39 | }
40 |
41 | /**
42 | * @based on WebKit's NodeTraversal::next
43 | * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L99
44 | */
45 | function next(node, stayWithin) {
46 | var n;
47 | n = node.firstChild;
48 | if (n !== null) {
49 | return n;
50 | }
51 | if (node === stayWithin) {
52 | return null;
53 | }
54 | n = node.nextSibling;
55 | if (n !== null) {
56 | return n;
57 | }
58 | return nextAncestorSibling(node, stayWithin);
59 | }
60 |
61 | /**
62 | * @based on WebKit's NodeTraversal::deepLastChild
63 | * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.cpp?rev=179143#L116
64 | */
65 | function deepLastChild(node) {
66 | while (node.lastChild) {
67 | node = node.lastChild;
68 | }
69 | return node;
70 | }
71 |
72 | /**
73 | * @based on WebKit's NodeTraversal::previous
74 | * https://trac.webkit.org/browser/trunk/Source/WebCore/dom/NodeTraversal.h?rev=179143#L121
75 | */
76 | function previous(node, stayWithin) {
77 | var p;
78 | p = node.previousSibling;
79 | if (p !== null) {
80 | return deepLastChild(p);
81 | }
82 | p = node.parentNode;
83 | if (p === stayWithin) {
84 | return null;
85 | }
86 | return p;
87 | }
88 |
--------------------------------------------------------------------------------
/lib/ContainerNode.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = ContainerNode;
3 |
4 | var Node = require('./Node');
5 | var NodeList = require('./NodeList');
6 |
7 | // This class defines common functionality for node subtypes that
8 | // can have children
9 |
10 | function ContainerNode() {
11 | Node.call(this);
12 | this._firstChild = this._childNodes = null;
13 | }
14 |
15 | // Primary representation is a circular linked list of siblings
16 | ContainerNode.prototype = Object.create(Node.prototype, {
17 |
18 | hasChildNodes: { value: function() {
19 | if (this._childNodes) {
20 | return this._childNodes.length > 0;
21 | }
22 | return this._firstChild !== null;
23 | }},
24 |
25 | childNodes: { get: function() {
26 | this._ensureChildNodes();
27 | return this._childNodes;
28 | }},
29 |
30 | firstChild: { get: function() {
31 | if (this._childNodes) {
32 | return this._childNodes.length === 0 ? null : this._childNodes[0];
33 | }
34 | return this._firstChild;
35 | }},
36 |
37 | lastChild: { get: function() {
38 | var kids = this._childNodes, first;
39 | if (kids) {
40 | return kids.length === 0 ? null: kids[kids.length-1];
41 | }
42 | first = this._firstChild;
43 | if (first === null) { return null; }
44 | return first._previousSibling; // circular linked list
45 | }},
46 |
47 | _ensureChildNodes: { value: function() {
48 | if (this._childNodes) { return; }
49 | var first = this._firstChild,
50 | kid = first,
51 | childNodes = this._childNodes = new NodeList();
52 | if (first) do {
53 | childNodes.push(kid);
54 | kid = kid._nextSibling;
55 | } while (kid !== first); // circular linked list
56 | this._firstChild = null; // free memory
57 | }},
58 |
59 | // Remove all of this node's children. This is a minor
60 | // optimization that only calls modify() once.
61 | removeChildren: { value: function removeChildren() {
62 | var root = this.rooted ? this.ownerDocument : null,
63 | next = this.firstChild,
64 | kid;
65 | while (next !== null) {
66 | kid = next;
67 | next = kid.nextSibling;
68 |
69 | if (root) root.mutateRemove(kid);
70 | kid.parentNode = null;
71 | }
72 | if (this._childNodes) {
73 | this._childNodes.length = 0;
74 | } else {
75 | this._firstChild = null;
76 | }
77 | this.modify(); // Update last modified type once only
78 | }},
79 |
80 | });
81 |
--------------------------------------------------------------------------------
/test/parsing.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var domino = require('../');
3 | var html5lib_tests = require('./html5lib-tests.json');
4 |
5 | // These test cases are taken from the `html5lib/html5lib-tests` package
6 | // on github, in the directory `tree-construction`. The filename in that
7 | // directory is the name of each suite of tests.
8 |
9 | function cases(filename, tc) {
10 | return tc.filter(function(test) {
11 | // We don't support some of these test cases...
12 | if (test.fragment && test.fragment.ns) { return false; }
13 | // Scripting is always enabled in domino.
14 | if (test.script === 'off') { return false; }
15 | return true;
16 | }).reduce(function(r, test) {
17 | var input = test.data, expected = test.document.html,
18 | fragment = test.fragment && test.fragment.name;
19 | // Come up with a helpful name for the testcase.
20 | var trimmed = input, n, candidate;
21 | if (trimmed==='') { trimmed = '{no input}'; }
22 | if (fragment) { trimmed = fragment + ':' + trimmed; }
23 | if (r[trimmed]) {
24 | //console.warn("Duplicate test in "+filename+": "+trimmed);
25 | }
26 | for (n = 40; n < trimmed.length; n += 5) {
27 | candidate = trimmed.slice(0, n) + '...';
28 | if (!r[candidate]) { trimmed = candidate; break; }
29 | }
30 | if (/\n/.test(trimmed)) {
31 | candidate = trimmed.split(/\n/)[0] + '...';
32 | if (!r[candidate]) { trimmed = candidate; }
33 | }
34 | r[trimmed] = makeOneTest(fragment, input, expected);
35 | return r;
36 | }, {});
37 | }
38 |
39 | function makeOneTest(fragment, input, expected) {
40 | return function() {
41 | var doc, context;
42 | if (fragment) {
43 | doc = domino.createDocument();
44 | context = (fragment==='body') ? doc.body : doc.createElement(fragment);
45 | context.innerHTML = input;
46 | context.innerHTML.should.equal(expected);
47 | } else {
48 | doc = domino.createDocument(input, true);
49 | doc.outerHTML.should.equal(expected);
50 | }
51 | };
52 | }
53 |
54 | exports.parseAlgorithm = Object.keys(html5lib_tests).reduce(function(r, file) {
55 | r[file] = cases(file, html5lib_tests[file]);
56 | return r;
57 | }, {});
58 |
59 | // Some extra tests.
60 |
61 | // https://github.com/html5lib/html5lib-tests/issues/20
62 | exports.parseAlgorithm['github issue #20'] = {
63 | 'test1': makeOneTest(
64 | 'body', '', ' '
65 | )
66 | };
67 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/files/collection.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NIST DOM HTML Test - SELECT
6 |
7 |
8 |
9 | Table Caption
10 |
11 |
12 |
13 |
14 | Position
15 | Salary
16 | Gender
17 | Address
18 |
19 |
20 |
21 |
22 | next page ...
23 | next page ...
24 | next page ...
25 | next page ...
26 | next page ...
27 | next page ...
28 |
29 |
30 |
31 |
32 | EMP0001
33 | Margaret Martin
34 | Accountant
35 | 56,000
36 | Female
37 | 1230 North Ave. Dallas, Texas 98551
38 |
39 |
40 | EMP0002
41 | Martha Raynolds
42 | Secretary
43 | 35,000
44 | Female
45 | 1900 Dallas Road Dallas, Texas 98554
46 |
47 |
48 |
49 |
50 |
51 |
52 | EMP10001
53 | EMP10002
54 | EMP10003
55 | EMP10004
56 | EMP10005
57 |
58 |
59 |
60 |
61 |
62 | EMP20001
63 | EMP20002
64 | EMP20003
65 | EMP20004
66 | EMP20005
67 |
68 |
69 |
70 |
71 | EMP30001
72 | EMP30002
73 | EMP30003
74 | EMP30004
75 | EMP30005
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/hasFeature01.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/hasFeature01";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | if (docsLoaded == 0) {
46 | setUpPageStatus = 'complete';
47 | }
48 | } catch(ex) {
49 | catchInitializationError(builder, ex);
50 | setUpPageStatus = 'complete';
51 | }
52 | }
53 |
54 |
55 |
56 | //
57 | // This method is called on the completion of
58 | // each asychronous load started in setUpTests.
59 | //
60 | // When every synchronous loaded document has completed,
61 | // the page status is changed which allows the
62 | // body of the test to be executed.
63 | function loadComplete() {
64 | if (++docsLoaded == 0) {
65 | setUpPageStatus = 'complete';
66 | }
67 | }
68 |
69 |
70 | /**
71 | *
72 | hasFeature("hTmL", null) should return true.
73 |
74 | * @author Curt Arnold
75 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-5CED94D7
76 | */
77 | function hasFeature01() {
78 | var success;
79 | if(checkInitialization(builder, "hasFeature01") != null) return;
80 | var doc;
81 | var domImpl;
82 | var version = null;
83 |
84 | var state;
85 | domImpl = getImplementation();
86 | state = domImpl.hasFeature("hTmL",version);
87 | assertTrue("hasHTMLnull",state);
88 |
89 | }
90 |
91 |
92 |
93 |
94 | function runTest() {
95 | hasFeature01();
96 | }
97 |
--------------------------------------------------------------------------------
/test/w3c/harness/index.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 | var vm = require('vm');
3 | var assert = require('assert');
4 | var util = require('util');
5 | var Path = require('path');
6 | var domino = require('../../../lib');
7 | var impl = domino.createDOMImplementation();
8 |
9 | var globals = {
10 | assertEquals: function(message, expected, actual) {
11 | assert.equal(actual, expected, message + ': expected ' +
12 | util.inspect(expected, false, 0) + ' got ' +
13 | util.inspect(actual, false, 0)
14 | );
15 | },
16 | assertTrue: function(message, actual) {
17 | globals.assertEquals(message, true, actual);
18 | },
19 | assertFalse: function(message, actual) {
20 | assert.ok(!actual, message);
21 | },
22 | assertNull: function(message, actual) {
23 | globals.assertEquals(message, null, actual);
24 | },
25 | assertNotNull: function(message, actual) {
26 | assert.notEqual(actual, null, message);
27 | },
28 | console: console
29 | };
30 |
31 | function list(dir, re, fn) {
32 | dir = Path.resolve(__dirname, '..', dir);
33 | fs.readdirSync(dir).forEach(function(file) {
34 | var path = Path.join(dir, file);
35 | var m = re.exec(path);
36 | if (m) fn.apply(null, m);
37 | });
38 | }
39 |
40 | module.exports = function(path) {
41 |
42 | function run(ctx, file) {
43 | vm.runInContext(fs.readFileSync(file, 'utf8'), ctx, file);
44 | return ctx;
45 | }
46 |
47 | function makeContext() {
48 | var ctx = vm.createContext(); // create new independent context
49 | Object.keys(globals).forEach(function(k) {
50 | ctx[k] = globals[k]; // shallow clone
51 | });
52 |
53 | ctx.createConfiguredBuilder = function() {
54 | return {
55 | contentType: 'text/html',
56 | hasFeature: function(feature, version) {
57 | return impl.hasFeature(feature, version);
58 | },
59 | getImplementation: function() {
60 | return impl;
61 | },
62 | setImplementationAttribute: function(attr, value) {
63 | // Ignore
64 | },
65 | preload: function(docRef, name, href) {
66 | return 1;
67 | },
68 | load: function(docRef, name, href) {
69 | var doc = Path.resolve(__dirname, '..', path, 'files', href) + '.html';
70 | var html = fs.readFileSync(doc, 'utf8');
71 | var url = 'http://example.com/'+Path.join(path,'files',href)+'.html';
72 | var win = domino.createWindow(html, url);
73 | return win.document;
74 | }
75 | };
76 | };
77 | run(ctx, __dirname + '/DomTestCase.js');
78 | return ctx;
79 | }
80 |
81 | var tests = {};
82 | list(path, /(.*?)\.js$/, function(file, basename) {
83 | tests[basename] = function() {
84 | var ctx = makeContext();
85 | run(ctx, file);
86 | ctx.setUpPage();
87 | ctx.runTest();
88 | };
89 | });
90 | return tests;
91 | };
92 |
--------------------------------------------------------------------------------
/lib/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var DOMImplementation = require('./DOMImplementation');
3 | var HTMLParser = require('./HTMLParser');
4 | var Window = require('./Window');
5 |
6 | exports.createDOMImplementation = function() {
7 | return new DOMImplementation(null);
8 | };
9 |
10 | exports.createDocument = function(html, force) {
11 | // Previous API couldn't let you pass '' as a document, and that
12 | // yields a slightly different document than createHTMLDocument('')
13 | // does. The new `force` parameter lets you pass '' if you want to.
14 | if (html || force) {
15 | var parser = new HTMLParser();
16 | parser.parse(html || '', true);
17 | return parser.document();
18 | }
19 | return new DOMImplementation(null).createHTMLDocument("");
20 | };
21 |
22 | exports.createIncrementalHTMLParser = function() {
23 | var parser = new HTMLParser();
24 | /** API for incremental parser. */
25 | return {
26 | /** Provide an additional chunk of text to be parsed. */
27 | write: function(s) {
28 | if (s.length > 0) {
29 | parser.parse(s, false, function() { return true; });
30 | }
31 | },
32 | /**
33 | * Signal that we are done providing input text, optionally
34 | * providing one last chunk as a parameter.
35 | */
36 | end: function(s) {
37 | parser.parse(s || '', true, function() { return true; });
38 | },
39 | /**
40 | * Performs a chunk of parsing work, returning at the end of
41 | * the next token as soon as shouldPauseFunc() returns true.
42 | * Returns true iff there is more work to do.
43 | *
44 | * For example:
45 | * ```
46 | * var incrParser = domino.createIncrementalHTMLParser();
47 | * incrParser.end('...long html document...');
48 | * while (true) {
49 | * // Pause every 10ms
50 | * var start = Date.now();
51 | * var pauseIn10 = function() { return (Date.now() - start) >= 10; };
52 | * if (!incrParser.process(pauseIn10)) {
53 | * break;
54 | * }
55 | * ...yield to other tasks, do other housekeeping, etc...
56 | * }
57 | * ```
58 | */
59 | process: function(shouldPauseFunc) {
60 | return parser.parse('', false, shouldPauseFunc);
61 | },
62 | /**
63 | * Returns the result of the incremental parse. Valid after
64 | * `this.end()` has been called and `this.process()` has returned
65 | * false.
66 | */
67 | document: function() {
68 | return parser.document();
69 | },
70 | };
71 | };
72 |
73 | exports.createWindow = function(html, address) {
74 | var document = exports.createDocument(html);
75 | if (address !== undefined) { document._address = address; }
76 | return new Window(document);
77 | };
78 |
79 | exports.impl = require('./impl');
80 |
--------------------------------------------------------------------------------
/lib/FilteredElementList.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = FilteredElementList;
3 |
4 | var Node = require('./Node');
5 |
6 | //
7 | // This file defines node list implementation that lazily traverses
8 | // the document tree (or a subtree rooted at any element) and includes
9 | // only those elements for which a specified filter function returns true.
10 | // It is used to implement the
11 | // {Document,Element}.getElementsBy{TagName,ClassName}{,NS} methods.
12 | //
13 | // XXX this should inherit from NodeList
14 |
15 | function FilteredElementList(root, filter) {
16 | this.root = root;
17 | this.filter = filter;
18 | this.lastModTime = root.lastModTime;
19 | this.done = false;
20 | this.cache = [];
21 | this.traverse();
22 | }
23 |
24 | FilteredElementList.prototype = Object.create(Object.prototype, {
25 | length: { get: function() {
26 | this.checkcache();
27 | if (!this.done) this.traverse();
28 | return this.cache.length;
29 | } },
30 |
31 | item: { value: function(n) {
32 | this.checkcache();
33 | if (!this.done && n >= this.cache.length) {
34 | // This can lead to O(N^2) behavior if we stop when we get to n
35 | // and the caller is iterating through the items in order; so
36 | // be sure to do the full traverse here.
37 | this.traverse(/*n*/);
38 | }
39 | return this.cache[n];
40 | } },
41 |
42 | checkcache: { value: function() {
43 | if (this.lastModTime !== this.root.lastModTime) {
44 | // subtree has changed, so invalidate cache
45 | for (var i = this.cache.length-1; i>=0; i--) {
46 | this[i] = undefined;
47 | }
48 | this.cache.length = 0;
49 | this.done = false;
50 | this.lastModTime = this.root.lastModTime;
51 | }
52 | } },
53 |
54 | // If n is specified, then traverse the tree until we've found the nth
55 | // item (or until we've found all items). If n is not specified,
56 | // traverse until we've found all items.
57 | traverse: { value: function(n) {
58 | // increment n so we can compare to length, and so it is never falsy
59 | if (n !== undefined) n++;
60 |
61 | var elt;
62 | while ((elt = this.next()) !== null) {
63 | this[this.cache.length] = elt; //XXX Use proxy instead
64 | this.cache.push(elt);
65 | if (n && this.cache.length === n) return;
66 | }
67 |
68 | // no next element, so we've found everything
69 | this.done = true;
70 | } },
71 |
72 | // Return the next element under root that matches filter
73 | next: { value: function() {
74 | var start = (this.cache.length === 0) ? this.root // Start at the root or at
75 | : this.cache[this.cache.length-1]; // the last element we found
76 |
77 | var elt;
78 | if (start.nodeType === Node.DOCUMENT_NODE)
79 | elt = start.documentElement;
80 | else
81 | elt = start.nextElement(this.root);
82 |
83 | while(elt) {
84 | if (this.filter(elt)) {
85 | return elt;
86 | }
87 |
88 | elt = elt.nextElement(this.root);
89 | }
90 | return null;
91 | } },
92 | });
93 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/HTMLDocument18.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLDocument18";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "document");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | Calls HTMLDocument.close on a document that has not been opened for modification.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-98948567
82 | */
83 | function HTMLDocument18() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLDocument18") != null) return;
86 | var doc;
87 |
88 | var docRef = null;
89 | if (typeof(this.doc) != 'undefined') {
90 | docRef = this.doc;
91 | }
92 | doc = load(docRef, "doc", "document");
93 | doc.close();
94 |
95 | }
96 |
97 |
98 |
99 |
100 | function runTest() {
101 | HTMLDocument18();
102 | }
103 |
--------------------------------------------------------------------------------
/test/tools/update-entities.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | 'use strict';
3 | var fs = require('fs');
4 | var path = require('path');
5 |
6 | /**
7 | * Process entities.json from the HTML5 spec into an array and regular
8 | * expression suitable for use in domino's HTMLParser.js implementation.
9 | */
10 | var entities_json = process.argv[2];
11 | var entities = require(path.resolve(__dirname, entities_json));
12 | var keys = Object.keys(entities).map(function(s) {
13 | console.assert(s[0] === '&');
14 | return s.slice(1); // Don't include leading '&'
15 | }).sort();
16 |
17 | var s = '';
18 | s += '/*\n';
19 | s += ' * This table is generated with test/tools/update-entities.js\n';
20 | s += ' */\n';
21 | s += 'var namedCharRefs = {\n __proto__: null,\n';
22 |
23 | for (var i=0; i0) { s+=','; }
34 | s += '0x' + c.charCodeAt(j).toString(16);
35 | }
36 | s += ']';
37 | }
38 | s += ',';
39 | if (i%2==1 || i===keys.length-1) { s+='\n'; }
40 | }
41 | s += '};\n';
42 |
43 | // Construct a regular expression matching exactly the keys of this table.
44 | var esc = function(s) { return s.replace(/[\^\\$*+?.()|{}\[\]\/]/g, '\\$&'); };
45 | var prefix = function(keys) {
46 | console.assert(keys.length>0 && keys[0].length>0);
47 | var first = '', subkeys, accept;
48 | var result = [];
49 | var emit = function() {
50 | if (first==='') { return; }
51 | var sub = subkeys.length > 0 ? prefix(subkeys) : [];
52 | if (accept) { sub.push(''); }
53 | sub = sub.length>1 ? ('(?:' + sub.join('|') + ')') : sub[0];
54 | if (sub==='(?:;|)') { sub = ';?'; /* optimization */ }
55 | result.push(esc(first) + sub);
56 | };
57 | for (var i=0; i1) {
65 | subkeys.push(keys[i].slice(1));
66 | } else {
67 | accept = true;
68 | }
69 | }
70 | emit();
71 | return result;
72 | };
73 | var re = prefix(keys).join('|');
74 | s += '/*\n';
75 | s += ' * This regexp is generated with test/tools/update-entities.js\n';
76 | s += ' * It will always match at least one character -- but note that there\n';
77 | s += ' * are no entities whose names are a single character long.\n';
78 | s += ' */\n';
79 | s += 'var NAMEDCHARREF = /(' + re + ')|[\\s\\S]/g;\n';
80 |
81 | // Verify the property mentioned in the comment above.
82 | var lens = keys.map(function(s) { return s.length; });
83 | var minlen = Math.min.apply(Math, lens);
84 | var maxlen = Math.max.apply(Math, lens);
85 | console.assert(minlen > 1);
86 |
87 | s += '\nvar NAMEDCHARREF_MAXLEN = ' + maxlen + ';\n';
88 |
89 | // Emit the result
90 | console.log(s);
91 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/doc01.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/doc01";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "anchor");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | Retrieve the title attribute of HTMLDocument and examine it's value.
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-18446827
83 | */
84 | function doc01() {
85 | var success;
86 | if(checkInitialization(builder, "doc01") != null) return;
87 | var vtitle;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "anchor");
95 | vtitle = doc.title;
96 |
97 | assertEquals("titleLink","NIST DOM HTML Test - Anchor",vtitle);
98 |
99 | }
100 |
101 |
102 |
103 |
104 | function runTest() {
105 | doc01();
106 | }
107 |
--------------------------------------------------------------------------------
/lib/DOMImplementation.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | module.exports = DOMImplementation;
3 |
4 | var Document = require('./Document');
5 | var DocumentType = require('./DocumentType');
6 | var HTMLParser = require('./HTMLParser');
7 | var utils = require('./utils');
8 | var xml = require('./xmlnames');
9 |
10 | // Each document must have its own instance of the domimplementation object
11 | function DOMImplementation(contextObject) {
12 | this.contextObject = contextObject;
13 | }
14 |
15 |
16 | // Feature/version pairs that DOMImplementation.hasFeature() returns
17 | // true for. It returns false for anything else.
18 | var supportedFeatures = {
19 | 'xml': { '': true, '1.0': true, '2.0': true }, // DOM Core
20 | 'core': { '': true, '2.0': true }, // DOM Core
21 | 'html': { '': true, '1.0': true, '2.0': true} , // HTML
22 | 'xhtml': { '': true, '1.0': true, '2.0': true} , // HTML
23 | };
24 |
25 | DOMImplementation.prototype = {
26 | hasFeature: function hasFeature(feature, version) {
27 | var f = supportedFeatures[(feature || '').toLowerCase()];
28 | return (f && f[version || '']) || false;
29 | },
30 |
31 | createDocumentType: function createDocumentType(qualifiedName, publicId, systemId) {
32 | if (!xml.isValidQName(qualifiedName)) utils.InvalidCharacterError();
33 |
34 | return new DocumentType(this.contextObject, qualifiedName, publicId, systemId);
35 | },
36 |
37 | createDocument: function createDocument(namespace, qualifiedName, doctype) {
38 | //
39 | // Note that the current DOMCore spec makes it impossible to
40 | // create an HTML document with this function, even if the
41 | // namespace and doctype are propertly set. See this thread:
42 | // http://lists.w3.org/Archives/Public/www-dom/2011AprJun/0132.html
43 | //
44 | var d = new Document(false, null);
45 | var e;
46 |
47 | if (qualifiedName)
48 | e = d.createElementNS(namespace, qualifiedName);
49 | else
50 | e = null;
51 |
52 | if (doctype) {
53 | d.appendChild(doctype);
54 | }
55 |
56 | if (e) d.appendChild(e);
57 | if (namespace === utils.NAMESPACE.HTML) {
58 | d._contentType = 'application/xhtml+xml';
59 | } else if (namespace === utils.NAMESPACE.SVG) {
60 | d._contentType = 'image/svg+xml';
61 | } else {
62 | d._contentType = 'application/xml';
63 | }
64 |
65 | return d;
66 | },
67 |
68 | createHTMLDocument: function createHTMLDocument(titleText) {
69 | var d = new Document(true, null);
70 | d.appendChild(new DocumentType(d, 'html'));
71 | var html = d.createElement('html');
72 | d.appendChild(html);
73 | var head = d.createElement('head');
74 | html.appendChild(head);
75 | if (titleText !== undefined) {
76 | var title = d.createElement('title');
77 | head.appendChild(title);
78 | title.appendChild(d.createTextNode(titleText));
79 | }
80 | html.appendChild(d.createElement('body'));
81 | d.modclock = 1; // Start tracking modifications
82 | return d;
83 | },
84 |
85 | mozSetOutputMutationHandler: function(doc, handler) {
86 | doc.mutationHandler = handler;
87 | },
88 |
89 | mozGetInputMutationHandler: function(doc) {
90 | utils.nyi();
91 | },
92 |
93 | mozHTMLParser: HTMLParser,
94 | };
95 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLFormElement10.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLFormElement10";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "form3");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | HTMLFormElement.submit submits the form.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-76767676
82 | */
83 | function HTMLFormElement10() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLFormElement10") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "form3");
95 | nodeList = doc.getElementsByTagName("form");
96 | assertSize("Asize",1,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.submit();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLFormElement10();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLSelectElement15.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLSelectElement15";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "select");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | blur should surrender input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-28216144
82 | */
83 | function HTMLSelectElement15() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLSelectElement15") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "select");
95 | nodeList = doc.getElementsByTagName("select");
96 | assertSize("Asize",3,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.blur();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLSelectElement15();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/HTMLAnchorElement13.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLAnchorElement13";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "anchor");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | HTMLAnchorElement.blur should surrender input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-65068939
82 | */
83 | function HTMLAnchorElement13() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLAnchorElement13") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "anchor");
95 | nodeList = doc.getElementsByTagName("a");
96 | assertSize("Asize",1,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.blur();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLAnchorElement13();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/HTMLAnchorElement14.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLAnchorElement14";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "anchor");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | HTMLAnchorElement.focus should capture input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-47150313
82 | */
83 | function HTMLAnchorElement14() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLAnchorElement14") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "anchor");
95 | nodeList = doc.getElementsByTagName("a");
96 | assertSize("Asize",1,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.focus();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLAnchorElement14();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/area02.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/area02";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "area");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 |
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-61826871
83 | */
84 | function area02() {
85 | var success;
86 | if(checkInitialization(builder, "area02") != null) return;
87 | var nodeList;
88 | var testNode;
89 | var vnohref;
90 | var doc;
91 |
92 | var docRef = null;
93 | if (typeof(this.doc) != 'undefined') {
94 | docRef = this.doc;
95 | }
96 | doc = load(docRef, "doc", "area");
97 | nodeList = doc.getElementsByTagName("area");
98 | assertSize("Asize",1,nodeList);
99 | testNode = nodeList.item(0);
100 | vnohref = testNode.noHref;
101 |
102 | assertFalse("noHrefLink",vnohref);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | area02();
111 | }
112 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLFormElement09.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLFormElement09";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "form2");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | HTMLFormElement.reset restores the forms default values.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-76767677
82 | */
83 | function HTMLFormElement09() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLFormElement09") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "form2");
95 | nodeList = doc.getElementsByTagName("form");
96 | assertSize("Asize",1,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.reset();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLFormElement09();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLInputElement19.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLInputElement19";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "input");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | HTMLInputElement.blur should surrender input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-26838235
82 | */
83 | function HTMLInputElement19() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLInputElement19") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "input");
95 | nodeList = doc.getElementsByTagName("input");
96 | assertSize("Asize",9,nodeList);
97 | testNode = nodeList.item(1);
98 | testNode.blur();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLInputElement19();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLInputElement20.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLInputElement20";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "input");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | HTMLInputElement.focus should capture input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-65996295
82 | */
83 | function HTMLInputElement20() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLInputElement20") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "input");
95 | nodeList = doc.getElementsByTagName("input");
96 | assertSize("Asize",9,nodeList);
97 | testNode = nodeList.item(1);
98 | testNode.focus();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLInputElement20();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLSelectElement14.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLSelectElement14";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "select");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | focus should give the select element input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-32130014
82 | */
83 | function HTMLSelectElement14() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLSelectElement14") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "select");
95 | nodeList = doc.getElementsByTagName("select");
96 | assertSize("Asize",3,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.focus();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLSelectElement14();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/obsolete/dlist01.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/dlist01";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "dl");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 |
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-21738539
83 | */
84 | function dlist01() {
85 | var success;
86 | if(checkInitialization(builder, "dlist01") != null) return;
87 | var nodeList;
88 | var testNode;
89 | var vcompact;
90 | var doc;
91 |
92 | var docRef = null;
93 | if (typeof(this.doc) != 'undefined') {
94 | docRef = this.doc;
95 | }
96 | doc = load(docRef, "doc", "dl");
97 | nodeList = doc.getElementsByTagName("dl");
98 | assertSize("Asize",1,nodeList);
99 | testNode = nodeList.item(0);
100 | vcompact = testNode.compact;
101 |
102 | assertTrue("compactLink",vcompact);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | dlist01();
111 | }
112 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/area01.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/area01";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "area");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 |
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-66021476
83 | */
84 | function area01() {
85 | var success;
86 | if(checkInitialization(builder, "area01") != null) return;
87 | var nodeList;
88 | var testNode;
89 | var vcoords;
90 | var doc;
91 |
92 | var docRef = null;
93 | if (typeof(this.doc) != 'undefined') {
94 | docRef = this.doc;
95 | }
96 | doc = load(docRef, "doc", "area");
97 | nodeList = doc.getElementsByTagName("area");
98 | assertSize("Asize",1,nodeList);
99 | testNode = nodeList.item(0);
100 | vcoords = testNode.coords;
101 |
102 | assertEquals("coordsLink","0,2,45,45",vcoords);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | area01();
111 | }
112 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/area03.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/area03";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "area");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 |
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-8722121
83 | */
84 | function area03() {
85 | var success;
86 | if(checkInitialization(builder, "area03") != null) return;
87 | var nodeList;
88 | var testNode;
89 | var vtabindex;
90 | var doc;
91 |
92 | var docRef = null;
93 | if (typeof(this.doc) != 'undefined') {
94 | docRef = this.doc;
95 | }
96 | doc = load(docRef, "doc", "area");
97 | nodeList = doc.getElementsByTagName("area");
98 | assertSize("Asize",1,nodeList);
99 | testNode = nodeList.item(0);
100 | vtabindex = testNode.tabIndex;
101 |
102 | assertEquals("tabIndexLink",10,vtabindex);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | area03();
111 | }
112 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/area04.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/area04";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "area");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 |
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-57944457
83 | */
84 | function area04() {
85 | var success;
86 | if(checkInitialization(builder, "area04") != null) return;
87 | var nodeList;
88 | var testNode;
89 | var vaccesskey;
90 | var doc;
91 |
92 | var docRef = null;
93 | if (typeof(this.doc) != 'undefined') {
94 | docRef = this.doc;
95 | }
96 | doc = load(docRef, "doc", "area");
97 | nodeList = doc.getElementsByTagName("area");
98 | assertSize("Asize",1,nodeList);
99 | testNode = nodeList.item(0);
100 | vaccesskey = testNode.accessKey;
101 |
102 | assertEquals("accessKeyLink","a",vaccesskey);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | area04();
111 | }
112 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLDocument12.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLDocument12";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "document");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | The cookie attribute returns the cookies associated with this document.
79 |
80 | Retrieve the cookie attribute and examine its value.
81 |
82 | * @author NIST
83 | * @author Rick Rivello
84 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-8747038
85 | */
86 | function HTMLDocument12() {
87 | var success;
88 | if(checkInitialization(builder, "HTMLDocument12") != null) return;
89 | var nodeList;
90 | var vcookie;
91 | var doc;
92 |
93 | var docRef = null;
94 | if (typeof(this.doc) != 'undefined') {
95 | docRef = this.doc;
96 | }
97 | doc = load(docRef, "doc", "document");
98 | vcookie = doc.cookie;
99 |
100 | assertEquals("cookieLink","",vcookie);
101 |
102 | }
103 |
104 |
105 |
106 |
107 | function runTest() {
108 | HTMLDocument12();
109 | }
110 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/HTMLDocument01.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLDocument01";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "document");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | The title attribute is the specified title as a string.
79 |
80 | Retrieve the title attribute and examine its value.
81 |
82 | * @author NIST
83 | * @author Mary Brady
84 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-18446827
85 | */
86 | function HTMLDocument01() {
87 | var success;
88 | if(checkInitialization(builder, "HTMLDocument01") != null) return;
89 | var nodeList;
90 | var vtitle;
91 | var doc;
92 |
93 | var docRef = null;
94 | if (typeof(this.doc) != 'undefined') {
95 | docRef = this.doc;
96 | }
97 | doc = load(docRef, "doc", "document");
98 | vtitle = doc.title;
99 |
100 | assertEquals("titleLink","NIST DOM HTML Test - DOCUMENT",vtitle);
101 |
102 | }
103 |
104 |
105 |
106 |
107 | function runTest() {
108 | HTMLDocument01();
109 | }
110 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLTextAreaElement13.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLTextAreaElement13";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "textarea");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | Calling HTMLTextAreaElement.blur should surrender input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-6750689
82 | */
83 | function HTMLTextAreaElement13() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLTextAreaElement13") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "textarea");
95 | nodeList = doc.getElementsByTagName("textarea");
96 | assertSize("Asize",3,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.blur();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLTextAreaElement13();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLTextAreaElement14.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLTextAreaElement14";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "textarea");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | Calling HTMLTextAreaElement.focus should capture input focus.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-39055426
82 | */
83 | function HTMLTextAreaElement14() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLTextAreaElement14") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "textarea");
95 | nodeList = doc.getElementsByTagName("textarea");
96 | assertSize("Asize",3,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.focus();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLTextAreaElement14();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLTextAreaElement15.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLTextAreaElement15";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "textarea");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | Calling HTMLTextAreaElement.select should select the text area.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-48880622
82 | */
83 | function HTMLTextAreaElement15() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLTextAreaElement15") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 |
90 | var docRef = null;
91 | if (typeof(this.doc) != 'undefined') {
92 | docRef = this.doc;
93 | }
94 | doc = load(docRef, "doc", "textarea");
95 | nodeList = doc.getElementsByTagName("textarea");
96 | assertSize("Asize",3,nodeList);
97 | testNode = nodeList.item(0);
98 | testNode.select();
99 |
100 | }
101 |
102 |
103 |
104 |
105 | function runTest() {
106 | HTMLTextAreaElement15();
107 | }
108 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLInputElement22.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLInputElement22";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "input");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | HTMLInputElement.select should select the contents of a text area.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-34677168
82 | */
83 | function HTMLInputElement22() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLInputElement22") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var doc;
89 | var checked;
90 |
91 | var docRef = null;
92 | if (typeof(this.doc) != 'undefined') {
93 | docRef = this.doc;
94 | }
95 | doc = load(docRef, "doc", "input");
96 | nodeList = doc.getElementsByTagName("input");
97 | assertSize("Asize",9,nodeList);
98 | testNode = nodeList.item(0);
99 | testNode.select();
100 |
101 | }
102 |
103 |
104 |
105 |
106 | function runTest() {
107 | HTMLInputElement22();
108 | }
109 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/HTMLScriptElement07.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLScriptElement07";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "script");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | event is described as for future use. Test accesses the value, but makes no assertions about its value.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-56700403
82 | */
83 | function HTMLScriptElement07() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLScriptElement07") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var event;
89 | var doc;
90 |
91 | var docRef = null;
92 | if (typeof(this.doc) != 'undefined') {
93 | docRef = this.doc;
94 | }
95 | doc = load(docRef, "doc", "script");
96 | nodeList = doc.getElementsByTagName("script");
97 | assertSize("Asize",1,nodeList);
98 | testNode = nodeList.item(0);
99 | event = testNode.event;
100 |
101 |
102 | }
103 |
104 |
105 |
106 |
107 | function runTest() {
108 | HTMLScriptElement07();
109 | }
110 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/HTMLScriptElement06.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLScriptElement06";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "script");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | htmlFor is described as for future use. Test accesses the value, but makes no assertions about its value.
79 |
80 | * @author Curt Arnold
81 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-66979266
82 | */
83 | function HTMLScriptElement06() {
84 | var success;
85 | if(checkInitialization(builder, "HTMLScriptElement06") != null) return;
86 | var nodeList;
87 | var testNode;
88 | var htmlFor;
89 | var doc;
90 |
91 | var docRef = null;
92 | if (typeof(this.doc) != 'undefined') {
93 | docRef = this.doc;
94 | }
95 | doc = load(docRef, "doc", "script");
96 | nodeList = doc.getElementsByTagName("script");
97 | assertSize("Asize",1,nodeList);
98 | testNode = nodeList.item(0);
99 | htmlFor = testNode.htmlFor;
100 |
101 |
102 | }
103 |
104 |
105 |
106 |
107 | function runTest() {
108 | HTMLScriptElement06();
109 | }
110 |
--------------------------------------------------------------------------------
/test/w3c/level1/core/hc_nodeelementnodevalue.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_nodeelementnodevalue";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "hc_staff");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | The string returned by the "getNodeValue()" method for an
79 | Element Node is null.
80 |
81 | * @author Curt Arnold
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-F68D080
83 | */
84 | function hc_nodeelementnodevalue() {
85 | var success;
86 | if(checkInitialization(builder, "hc_nodeelementnodevalue") != null) return;
87 | var doc;
88 | var elementNode;
89 | var elementValue;
90 |
91 | var docRef = null;
92 | if (typeof(this.doc) != 'undefined') {
93 | docRef = this.doc;
94 | }
95 | doc = load(docRef, "doc", "hc_staff");
96 | elementNode = doc.documentElement;
97 |
98 | elementValue = elementNode.nodeValue;
99 |
100 | assertNull("elementNodeValue",elementValue);
101 |
102 | }
103 |
104 |
105 |
106 |
107 | function runTest() {
108 | hc_nodeelementnodevalue();
109 | }
110 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/HTMLLabelElement01.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLLabelElement01";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "label");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | The form attribute returns the FORM element containing this control.
79 |
80 | Retrieve the form attribute and examine its value.
81 |
82 | * @author NIST
83 | * @author Mary Brady
84 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-32480901
85 | */
86 | function HTMLLabelElement01() {
87 | var success;
88 | if(checkInitialization(builder, "HTMLLabelElement01") != null) return;
89 | var nodeList;
90 | var testNode;
91 | var vform;
92 | var fNode;
93 | var doc;
94 |
95 | var docRef = null;
96 | if (typeof(this.doc) != 'undefined') {
97 | docRef = this.doc;
98 | }
99 | doc = load(docRef, "doc", "label");
100 | nodeList = doc.getElementsByTagName("label");
101 | assertSize("Asize",2,nodeList);
102 | }
103 |
104 |
105 |
106 |
107 | function runTest() {
108 | HTMLLabelElement01();
109 | }
110 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLDocument02.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLDocument02";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "document");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | The referrer attribute returns the URI of the page that linked to this
79 | page.
80 |
81 | Retrieve the referrer attribute and examine its value.
82 |
83 | * @author NIST
84 | * @author Mary Brady
85 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-95229140
86 | */
87 | function HTMLDocument02() {
88 | var success;
89 | if(checkInitialization(builder, "HTMLDocument02") != null) return;
90 | var nodeList;
91 | var testNode;
92 | var vreferrer;
93 | var doc;
94 |
95 | var docRef = null;
96 | if (typeof(this.doc) != 'undefined') {
97 | docRef = this.doc;
98 | }
99 | doc = load(docRef, "doc", "document");
100 | vreferrer = doc.referrer;
101 |
102 | assertEquals("referrerLink","",vreferrer);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | HTMLDocument02();
111 | }
112 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/nyi/HTMLDocument04.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLDocument04";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "HTMLDocument04");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | The URL attribute specifies the absolute URI of the document.
79 |
80 | Retrieve the URL attribute and examine its value.
81 |
82 | * @author NIST
83 | * @author Mary Brady
84 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-46183437
85 | */
86 | function HTMLDocument04() {
87 | var success;
88 | if(checkInitialization(builder, "HTMLDocument04") != null) return;
89 | var nodeList;
90 | var testNode;
91 | var vurl;
92 | var doc;
93 |
94 | var docRef = null;
95 | if (typeof(this.doc) != 'undefined') {
96 | docRef = this.doc;
97 | }
98 | doc = load(docRef, "doc", "HTMLDocument04");
99 | vurl = doc.URL;
100 |
101 | assertURIEquals("URLLink",null,null,null,null,"HTMLDocument04",null,null,true,vurl);
102 |
103 | }
104 |
105 |
106 |
107 |
108 | function runTest() {
109 | HTMLDocument04();
110 | }
111 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/object14.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/object14";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "object");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | The value of attribute width of the object element is read and checked against the expected value.
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-38538620
83 | */
84 | function object14() {
85 | var success;
86 | if(checkInitialization(builder, "object14") != null) return;
87 | var nodeList;
88 | var testNode;
89 | var vwidth;
90 | var doc;
91 |
92 | var docRef = null;
93 | if (typeof(this.doc) != 'undefined') {
94 | docRef = this.doc;
95 | }
96 | doc = load(docRef, "doc", "object");
97 | nodeList = doc.getElementsByTagName("object");
98 | assertSize("Asize",2,nodeList);
99 | testNode = nodeList.item(0);
100 | vwidth = testNode.width;
101 |
102 | assertEquals("widthLink","550",vwidth);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | object14();
111 | }
112 |
--------------------------------------------------------------------------------
/test/w3c/level1/html/button01.js:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright © 2001-2004 World Wide Web Consortium,
4 | (Massachusetts Institute of Technology, European Research Consortium
5 | for Informatics and Mathematics, Keio University). All
6 | Rights Reserved. This work is distributed under the W3C® Software License [1] in the
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 |
10 | [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11 | */
12 |
13 |
14 |
15 | /**
16 | * Gets URI that identifies the test.
17 | * @return uri identifier of test
18 | */
19 | function getTargetURI() {
20 | return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/button01";
21 | }
22 |
23 | var docsLoaded = -1000000;
24 | var builder = null;
25 |
26 | //
27 | // This function is called by the testing framework before
28 | // running the test suite.
29 | //
30 | // If there are no configuration exceptions, asynchronous
31 | // document loading is started. Otherwise, the status
32 | // is set to complete and the exception is immediately
33 | // raised when entering the body of the test.
34 | //
35 | function setUpPage() {
36 | setUpPageStatus = 'running';
37 | try {
38 | //
39 | // creates test document builder, may throw exception
40 | //
41 | builder = createConfiguredBuilder();
42 |
43 | docsLoaded = 0;
44 |
45 | var docRef = null;
46 | if (typeof(this.doc) != 'undefined') {
47 | docRef = this.doc;
48 | }
49 | docsLoaded += preload(docRef, "doc", "button");
50 |
51 | if (docsLoaded == 1) {
52 | setUpPageStatus = 'complete';
53 | }
54 | } catch(ex) {
55 | catchInitializationError(builder, ex);
56 | setUpPageStatus = 'complete';
57 | }
58 | }
59 |
60 |
61 |
62 | //
63 | // This method is called on the completion of
64 | // each asychronous load started in setUpTests.
65 | //
66 | // When every synchronous loaded document has completed,
67 | // the page status is changed which allows the
68 | // body of the test to be executed.
69 | function loadComplete() {
70 | if (++docsLoaded == 1) {
71 | setUpPageStatus = 'complete';
72 | }
73 | }
74 |
75 |
76 | /**
77 | *
78 | Returns the FORM element containing this control. Returns null if this control is not within the context of a form.
79 |
80 | * @author Netscape
81 | * @author Sivakiran Tummala
82 | * @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-71254493
83 | */
84 | function button01() {
85 | var success;
86 | if(checkInitialization(builder, "button01") != null) return;
87 | var nodeList;
88 | var testNode;
89 | var vform;
90 | var doc;
91 |
92 | var docRef = null;
93 | if (typeof(this.doc) != 'undefined') {
94 | docRef = this.doc;
95 | }
96 | doc = load(docRef, "doc", "button");
97 | nodeList = doc.getElementsByTagName("button");
98 | assertSize("Asize",2,nodeList);
99 | testNode = nodeList.item(1);
100 | vform = testNode.form;
101 |
102 | assertNull("formLink",vform);
103 |
104 | }
105 |
106 |
107 |
108 |
109 | function runTest() {
110 | button01();
111 | }
112 |
--------------------------------------------------------------------------------