-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Test from TtWF #76
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE html> | ||
<html xmlns:h="http://www.w3.org/2000/xhtml"> | ||
<head> | ||
<meta charset="utf-8"> | ||
|
||
<title id='title'>HTMLOptionsCollection 2.8.3.2</title> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testharness.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong order. testharnessreport should come after testharness. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done and committed |
||
|
||
<div id="log"></div> | ||
<select id="selly"> | ||
<option>1</option> | ||
<option>2</option> | ||
<option>3</option> | ||
<option>4</option> | ||
</select> | ||
|
||
<script> | ||
(function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrap this all in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done and committed |
||
//test asserts go here | ||
var selly = document.getElementById('selly'); | ||
var initval = selly.length; | ||
var midval = 0; | ||
var firecount = 0; | ||
selly.addEventListener('DOMNodeInserted', firecounter) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use mutation events. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. Split out the mutation event test into an async test with observers? |
||
|
||
function firecounter() { | ||
firecount++; | ||
} | ||
|
||
test(function () { | ||
assert_equals(selly.length, 4); | ||
}, "On getting, the length attribute must return the number of nodes represented by the collection."); | ||
|
||
selly.length = 7; | ||
test(function () { | ||
assert_equals(selly.length, 7); | ||
}, "Changing the length adds new nodes"); | ||
|
||
test(function () { | ||
midval = selly.length; | ||
assert_equals(midval - initval, 3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is correct, but since you've already testes that one is 7 and the other is 4, I don't really see the point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed. |
||
}, "The number of new nodes = new length minus old length"); | ||
|
||
var elarray = []; | ||
for (var i = 0; i < selly.length; i++) { | ||
elarray.push(selly[i].value); | ||
} | ||
|
||
test(function () { | ||
assert_array_equals(elarray, ["1", "2", "3", "4", "", "", ""]); | ||
}, "New nodes have no value"); | ||
|
||
test(function () { | ||
assert_equals(firecount, 3); | ||
}, "Changing the length & adding new nodes fires DOMNodeInserted on the select once for each new element"); | ||
|
||
selly.length = 7; | ||
test(function () { | ||
assert_equals(selly.length, 7); | ||
}, "Setting a length equal to existing length changes nothing"); | ||
|
||
|
||
selly.length = 4; | ||
test(function () { | ||
assert_equals(selly[6], null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect; at this point, 6 is no longer a supported property index, so getting that property will return undefined. Calling item(6) would return null, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to undefined |
||
}, "Setting a length lower than the old length trims nodes from the end (checking that previously set node is now null)"); | ||
|
||
test(function () { | ||
var newdiff = midval - selly.length; | ||
assert_equals(newdiff, 3); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably clearer to just test that .length returns 4 now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adjusted test and committed |
||
}, "Number of nodes trimmed from the end is equal to old length - new length"); | ||
|
||
})(); | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the xmlns:h attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and committed