diff --git a/html/dom/interfaces.https.html b/html/dom/interfaces.https.html index 6ca7721253200d..433d802d5cd0b5 100644 --- a/html/dom/interfaces.https.html +++ b/html/dom/interfaces.https.html @@ -40,6 +40,14 @@

HTML IDL tests

['html'], ['SVG', 'cssom', 'touch-events', 'uievents', 'dom', 'xhr'], async idlArray => { + self.documentWithHandlers = new Document(); + const handler = function(e) {}; + for (const callback of idlArray.members['GlobalEventHandlers'].members) { + if (callback.idlType && callback.idlType.idlType === 'EventHandler') { + documentWithHandlers[callback.name] = handler; + } + } + idlArray.add_objects({ NodeList: ['document.getElementsByName("name")'], HTMLAllCollection: ['document.all'], @@ -48,7 +56,7 @@

HTML IDL tests

HTMLOptionsCollection: ['document.createElement("select").options'], DOMStringMap: ['document.head.dataset'], Transferable: [], - Document: ['iframe.contentDocument', 'new Document()'], + Document: ['iframe.contentDocument', 'new Document()', 'documentWithHandlers'], XMLDocument: ['document.implementation.createDocument(null, "", null)'], HTMLElement: ['document.createElement("noscript")'], // more tests in html/semantics/interfaces.js HTMLUnknownElement: ['document.createElement("bgsound")'], // more tests in html/semantics/interfaces.js diff --git a/resources/idlharness.js b/resources/idlharness.js index 9be554d96b6e29..056540ad93a812 100644 --- a/resources/idlharness.js +++ b/resources/idlharness.js @@ -488,8 +488,7 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls, options) break; case "callback": - // TODO - console.log("callback not yet supported"); + this.members[parsed_idl.name] = new IdlCallback(parsed_idl); break; case "enum": @@ -1163,9 +1162,13 @@ IdlArray.prototype.assert_type_is = function(value, type) { // TODO: Test when we actually have something to test this on } + else if (this.members[type] instanceof IdlCallback) + { + assert_equals(typeof value, "function"); + } else { - throw new IdlHarnessError("Type " + type + " isn't an interface or dictionary"); + throw new IdlHarnessError("Type " + type + " isn't an interface, callback or dictionary"); } }; @@ -3096,6 +3099,24 @@ function IdlEnum(obj) IdlEnum.prototype = Object.create(IdlObject.prototype); +/// IdlCallback /// +// Used for IdlArray.prototype.assert_type_is +function IdlCallback(obj) +{ + /** + * obj is an object produced by the WebIDLParser.js "callback" + * production. + */ + + /** Self-explanatory. */ + this.name = obj.name; + + /** Arguments for the callback. */ + this.arguments = obj.arguments; +} + +IdlCallback.prototype = Object.create(IdlObject.prototype); + /// IdlTypedef /// // Used for IdlArray.prototype.assert_type_is function IdlTypedef(obj)