Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdartus committed Sep 18, 2019
1 parent 327a911 commit cf21cd1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
8 changes: 6 additions & 2 deletions lib/jsdom/living/helpers/ce-reactions.js
@@ -1,6 +1,7 @@
"use strict";

const { CUSTOM_ELEMENT_REACTIONS_STACK, invokeCEReactions } = require("./custom-elements");
const idlUtils = require("../generated/utils");

/**
* Mapping of all the property interfaces that are marked with the [CEReaction] attributes.
Expand Down Expand Up @@ -349,7 +350,9 @@ const CE_REACTIONS_INTERFACES = {
"bgColor"
],
HTMLTimeElement: ["dateTime"],
DOMStringMap: ["void"],
DOMStringMap: [
"void"
],
HTMLElement: [
"title",
"lang",
Expand Down Expand Up @@ -672,5 +675,6 @@ function patchInterfaces(interfaces) {
}

module.exports = {
patchInterfaces
patchInterfaces,
wrapWithCEReactions
};
13 changes: 11 additions & 2 deletions lib/jsdom/living/nodes/DOMStringMap-impl.js
Expand Up @@ -4,6 +4,7 @@ const idlUtils = require("../generated/utils.js");
const { setAttributeValue, removeAttributeByName } = require("../attributes");
const validateName = require("../helpers/validate-names").name;
const DOMException = require("domexception");
const { wrapWithCEReactions } = require("../helpers/ce-reactions");

const dataAttrRe = /^data-([^A-Z]*)$/;

Expand All @@ -15,7 +16,7 @@ function attrSnakeCase(name) {
return name.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`);
}

exports.implementation = class DOMStringMapImpl {
class DOMStringMapImpl {
constructor(args, privateData) {
this._element = privateData.element;
}
Expand Down Expand Up @@ -57,4 +58,12 @@ exports.implementation = class DOMStringMapImpl {
name = `data-${attrSnakeCase(name)}`;
removeAttributeByName(this._element, name);
}
};
}

// This is poor work-around to make [CEReactions] work with interfaces using proxies.
// Instead of patching the interfaces, in those cases we patch directly the class impl
DOMStringMapImpl.prototype[idlUtils.namedSetNew] = wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedSetNew]);
DOMStringMapImpl.prototype[idlUtils.namedSetExisting] = wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedSetExisting]);
DOMStringMapImpl.prototype[idlUtils.namedDelete] = wrapWithCEReactions(DOMStringMapImpl.prototype[idlUtils.namedDelete]);

exports.implementation = DOMStringMapImpl;
17 changes: 8 additions & 9 deletions test/web-platform-tests/to-run.yaml
Expand Up @@ -104,21 +104,20 @@ microtasks-and-constructors.html: [fail, Usage of external scripts doesn't block
parser/parser-constructs-custom-element-synchronously.html: [fail, Usage of external scripts doesn't block HTML parsing, https://github.com/jsdom/jsdom/issues/2413]
parser/parser-sets-attributes-and-children.html: [fail, Usage of external scripts doesn't block HTML parsing, https://github.com/jsdom/jsdom/issues/2413]
parser/parser-uses-constructed-element.html: [fail, Usage of external scripts doesn't block HTML parsing, https://github.com/jsdom/jsdom/issues/2413]
# parser/parser-uses-registry-of-owner-document.html: [fail, TODO]
parser/parser-uses-registry-of-owner-document.html: [fail, TODO]
parser/serializing-html-fragments.html: [fail, parse5 doesn't support is attribute for serialization]
perform-microtask-checkpoint-before-construction.html: [fail, TODO]
perform-microtask-checkpoint-before-construction.html: [fail, impossible to implement microtask checkpoint without patching Promise]
pseudo-class-defined.html: [timeout, :defined is not defined and throws]
range-and-constructors.html: [fail, TODO]
reactions/CSSStyleDeclaration.html: [fail, TODO]
reactions/DOMStringMap.html: [fail, TODO]
range-and-constructors.html: [fail, Range is not implemented]
reactions/CSSStyleDeclaration.html: [fail, CSSStyleDeclaration is not implemented using wedidl2js]
reactions/Document.html: [fail, TODO]
reactions/ElementContentEditable.html: [fail, TODO]
reactions/HTMLButtonElement.html: [fail, TODO]
reactions/ElementContentEditable.html: [fail, contentEditable is not implemented]
# reactions/HTMLButtonElement.html: [fail, TODO]
reactions/HTMLElement.html: [fail, TODO]
reactions/HTMLOptionsCollection.html: [fail, TODO]
reactions/HTMLSelectElement.html: [fail, TODO]
reactions/Range.html: [fail, TODO]
reactions/Selection.html: [fail, TODO]
reactions/Range.html: [fail, Range is not implemented]
reactions/Selection.html: [fail, Selection is not implemented]
throw-on-dynamic-markup-insertion-counter-construct.html: [timeout, TODO]
throw-on-dynamic-markup-insertion-counter-reactions.html: [timeout, TODO]
upgrading/Document-importNode.html: [fail, TODO]
Expand Down

0 comments on commit cf21cd1

Please sign in to comment.