Skip to content
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

Test attributes that only reflect on setting with reflection.js. #1348

Merged
merged 3 commits into from
Nov 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion html/dom/elements-embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var embeddedElements = {
crossOrigin: {type: "enum", keywords: ["", "anonymous", "use-credentials"]},
useMap: "string",
isMap: "boolean",
// TODO: width/height reflect for setting, but not for getting.
width: {type: "unsigned long", customGetter: true},
height: {type: "unsigned long", customGetter: true},

// Obsolete
name: "string",
Expand Down
2 changes: 2 additions & 0 deletions html/dom/elements-forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ var formElements = {
},
option: {
disabled: "boolean",
label: {type: "string", customGetter: true},
defaultSelected: {type: "boolean", domAttrName: "selected"},
value: {type: "string", customGetter: true},
},
textarea: {
// TODO: autocomplete is special.
Expand Down
40 changes: 21 additions & 19 deletions html/dom/reflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,26 +685,28 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
idlIdlExpected = idlIdlExpected.filter(function(element, index, array) { return idlIdlExpected[index] < 1000; });
}

for (var i = 0; i < domTests.length; i++) {
if (domExpected[i] === null) {
// If you follow all the complicated logic here, you'll find that
// this will only happen if there's no expected value at all (like
// for tabIndex, where the default is too complicated). So skip
// the test.
continue;
}
try {
domObj.setAttribute(domName, domTests[i]);
ReflectionHarness.test(domObj.getAttribute(domName), domTests[i] + "", "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by getAttribute()");
ReflectionHarness.test(idlObj[idlName], domExpected[i], "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by IDL get");
if (ReflectionHarness.catchUnexpectedExceptions) {
ReflectionHarness.success();
if (!data.customGetter) {
for (var i = 0; i < domTests.length; i++) {
if (domExpected[i] === null) {
// If you follow all the complicated logic here, you'll find that
// this will only happen if there's no expected value at all (like
// for tabIndex, where the default is too complicated). So skip
// the test.
continue;
}
} catch (err) {
if (ReflectionHarness.catchUnexpectedExceptions) {
ReflectionHarness.failure("Exception thrown during tests with setAttribute() to " + ReflectionHarness.stringRep(domTests[i]));
} else {
throw err;
try {
domObj.setAttribute(domName, domTests[i]);
ReflectionHarness.test(domObj.getAttribute(domName), domTests[i] + "", "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by getAttribute()");
ReflectionHarness.test(idlObj[idlName], domExpected[i], "setAttribute() to " + ReflectionHarness.stringRep(domTests[i]) + " followed by IDL get");
if (ReflectionHarness.catchUnexpectedExceptions) {
ReflectionHarness.success();
}
} catch (err) {
if (ReflectionHarness.catchUnexpectedExceptions) {
ReflectionHarness.failure("Exception thrown during tests with setAttribute() to " + ReflectionHarness.stringRep(domTests[i]));
} else {
throw err;
}
}
}
}
Expand Down