From 91c61ae7519956ddc22240a6db262c2fadd4cd13 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 21 Jul 2015 15:32:57 -0700 Subject: [PATCH 1/3] Tidy finds WebIDLs with no spec. Closes #6689 --- .../script/dom/webidls/BrowserElement.webidl | 2 + .../script/dom/webidls/CanvasPattern.webidl | 2 + .../script/dom/webidls/ErrorEvent.webidl | 2 + .../script/dom/webidls/HTMLCollection.webidl | 2 + .../script/dom/webidls/NamedNodeMap.webidl | 2 + .../script/dom/webidls/ServoHTMLParser.webidl | 3 ++ .../script/dom/webidls/TestBinding.webidl | 3 ++ .../dom/webidls/TestBindingProxy.webidl | 3 ++ .../script/dom/webidls/WebSocket.webidl | 2 + python/tidy.py | 52 ++++++++++++++++++- 10 files changed, 72 insertions(+), 1 deletion(-) diff --git a/components/script/dom/webidls/BrowserElement.webidl b/components/script/dom/webidls/BrowserElement.webidl index f36f3b8a408..27289b5a85d 100644 --- a/components/script/dom/webidls/BrowserElement.webidl +++ b/components/script/dom/webidls/BrowserElement.webidl @@ -4,6 +4,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser + callback BrowserElementNextPaintEventCallback = void (); //dictionary BrowserElementDownloadOptions { diff --git a/components/script/dom/webidls/CanvasPattern.webidl b/components/script/dom/webidls/CanvasPattern.webidl index 06a77d0a62d..889682e395c 100644 --- a/components/script/dom/webidls/CanvasPattern.webidl +++ b/components/script/dom/webidls/CanvasPattern.webidl @@ -3,6 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// https://html.spec.whatwg.org/multipage/scripting.html#canvaspattern + interface CanvasPattern { //void setTransform(SVGMatrix matrix); }; diff --git a/components/script/dom/webidls/ErrorEvent.webidl b/components/script/dom/webidls/ErrorEvent.webidl index 824cf5f1d18..670ef38685d 100644 --- a/components/script/dom/webidls/ErrorEvent.webidl +++ b/components/script/dom/webidls/ErrorEvent.webidl @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// https://html.spec.whatwg.org/multipage/webappapis.html#the-errorevent-interface + [Constructor(DOMString type, optional ErrorEventInit eventInitDict)/*, Exposed=(Window,Worker)*/] interface ErrorEvent : Event { readonly attribute DOMString message; diff --git a/components/script/dom/webidls/HTMLCollection.webidl b/components/script/dom/webidls/HTMLCollection.webidl index 26227c54c4a..693984bcbb8 100644 --- a/components/script/dom/webidls/HTMLCollection.webidl +++ b/components/script/dom/webidls/HTMLCollection.webidl @@ -3,6 +3,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-75708506 + interface HTMLCollection { readonly attribute unsigned long length; getter Element? item(unsigned long index); diff --git a/components/script/dom/webidls/NamedNodeMap.webidl b/components/script/dom/webidls/NamedNodeMap.webidl index 5b85e755804..8c21bacd1b7 100644 --- a/components/script/dom/webidls/NamedNodeMap.webidl +++ b/components/script/dom/webidls/NamedNodeMap.webidl @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// https://dom.spec.whatwg.org/#interface-namednodemap + interface NamedNodeMap { readonly attribute unsigned long length; getter Attr? item(unsigned long index); diff --git a/components/script/dom/webidls/ServoHTMLParser.webidl b/components/script/dom/webidls/ServoHTMLParser.webidl index 02ad2667a96..c90b28a1376 100644 --- a/components/script/dom/webidls/ServoHTMLParser.webidl +++ b/components/script/dom/webidls/ServoHTMLParser.webidl @@ -3,6 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// This interface is entirely internal to Servo, and should not be accessible to +// web pages. + // FIXME: find a better way to hide this from content (#3688) [NoInterfaceObject] interface ServoHTMLParser { diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl index 0ebf0a41126..379f3e1e51c 100644 --- a/components/script/dom/webidls/TestBinding.webidl +++ b/components/script/dom/webidls/TestBinding.webidl @@ -2,6 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// This interface is entirely internal to Servo, and should not be accessible to +// web pages. + enum TestEnum { "", "foo", "bar" }; dictionary TestDictionary { diff --git a/components/script/dom/webidls/TestBindingProxy.webidl b/components/script/dom/webidls/TestBindingProxy.webidl index ed578f50f0d..4d01200f405 100644 --- a/components/script/dom/webidls/TestBindingProxy.webidl +++ b/components/script/dom/webidls/TestBindingProxy.webidl @@ -9,6 +9,9 @@ * */ +// This interface is entirely internal to Servo, and should not be accessible to +// web pages. + interface TestBindingProxy : TestBinding { getter DOMString getNamedItem(DOMString name); diff --git a/components/script/dom/webidls/WebSocket.webidl b/components/script/dom/webidls/WebSocket.webidl index 3fd2fcd403d..4233a0d50b9 100644 --- a/components/script/dom/webidls/WebSocket.webidl +++ b/components/script/dom/webidls/WebSocket.webidl @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +// https://w3c.github.io/websockets/#the-websocket-interface + enum BinaryType { "blob", "arraybuffer" }; [Constructor(DOMString url)] diff --git a/python/tidy.py b/python/tidy.py index 6050efc456c..6c04cc8b51b 100644 --- a/python/tidy.py +++ b/python/tidy.py @@ -15,7 +15,7 @@ import sys import toml from licenseck import licenses -filetypes_to_check = [".rs", ".rc", ".cpp", ".c", ".h", ".py", ".toml"] +filetypes_to_check = [".rs", ".rc", ".cpp", ".c", ".h", ".py", ".toml", ".webidl"] reftest_directories = ["tests/ref"] reftest_filetype = ".list" python_dependencies = [ @@ -153,6 +153,53 @@ def check_toml(contents): yield (idx + 1, "found asterisk instead of minimum version number") +def check_webidl_spec(contents): + # Sorted by this function (in pseudo-Rust). The idea is to group the same + # organization together. + # fn sort_standards(a: &Url, b: &Url) -> Ordering { + # let a_domain = a.domain().split("."); + # a_domain.pop(); + # a_domain.reverse(); + # let b_domain = b.domain().split("."); + # b_domain.pop(); + # b_domain.reverse(); + # for i in a_domain.into_iter().zip(b_domain.into_iter()) { + # match i.0.cmp(b.0) { + # Less => return Less, + # Greater => return Greater, + # _ => (), + # } + # } + # a_domain.path().cmp(b_domain.path()) + # } + standards = [ + "//w3c.github.io", + "//www.khronos.org/registry/webgl/specs", + "//developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser", + "//developer.mozilla.org/en-US/docs/Web/API", + "//dev.w3.org/2006/webapi", + "//dev.w3.org/csswg", + "//dev.w3.org/fxtf", + "//dvcs.w3.org/hg", + "//www.w3.org/TR", + "//dom.spec.whatwg.org", + "//domparsing.spec.whatwg.org", + "//encoding.spec.whatwg.org", + "//html.spec.whatwg.org", + "//url.spec.whatwg.org", + "//xhr.spec.whatwg.org", + "//www.whatwg.org/html", + "//www.whatwg.org/specs", + # Not a URL + "// This interface is entirely internal to Servo, and should not be" + + " accessible to\n// web pages." + ] + for i in standards: + if contents.find(i) != -1: + return True + return False + + def collect_errors_for_files(files_to_check, checking_functions): for file_name in files_to_check: with open(file_name, "r") as fp: @@ -160,6 +207,9 @@ def collect_errors_for_files(files_to_check, checking_functions): if file_name.endswith(".toml"): for error in check_toml(contents): yield (file_name, error[0], error[1]) + elif file_name.endswith(".webidl"): + if not check_webidl_spec(contents): + yield (file_name, 0, "No specification link found.") else: for check in checking_functions: for error in check(contents): From 970f018dc8cd70254856ca702db28de892bdf947 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 22 Jul 2015 10:49:26 -0700 Subject: [PATCH 2/3] Better references. --- components/script/dom/webidls/BrowserElement.webidl | 2 +- components/script/dom/webidls/CanvasPattern.webidl | 2 +- components/script/dom/webidls/ErrorEvent.webidl | 2 +- components/script/dom/webidls/HTMLCollection.webidl | 2 +- components/script/dom/webidls/WebSocket.webidl | 2 +- python/tidy.py | 2 -- 6 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/script/dom/webidls/BrowserElement.webidl b/components/script/dom/webidls/BrowserElement.webidl index 27289b5a85d..e719a3b9bbb 100644 --- a/components/script/dom/webidls/BrowserElement.webidl +++ b/components/script/dom/webidls/BrowserElement.webidl @@ -4,7 +4,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ -// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser +// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API callback BrowserElementNextPaintEventCallback = void (); diff --git a/components/script/dom/webidls/CanvasPattern.webidl b/components/script/dom/webidls/CanvasPattern.webidl index 889682e395c..a1ddf8982c0 100644 --- a/components/script/dom/webidls/CanvasPattern.webidl +++ b/components/script/dom/webidls/CanvasPattern.webidl @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -// https://html.spec.whatwg.org/multipage/scripting.html#canvaspattern +// https://html.spec.whatwg.org/multipage/#canvaspattern interface CanvasPattern { //void setTransform(SVGMatrix matrix); diff --git a/components/script/dom/webidls/ErrorEvent.webidl b/components/script/dom/webidls/ErrorEvent.webidl index 670ef38685d..e56b70ebb1d 100644 --- a/components/script/dom/webidls/ErrorEvent.webidl +++ b/components/script/dom/webidls/ErrorEvent.webidl @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -// https://html.spec.whatwg.org/multipage/webappapis.html#the-errorevent-interface +// https://html.spec.whatwg.org/multipage/#the-errorevent-interface [Constructor(DOMString type, optional ErrorEventInit eventInitDict)/*, Exposed=(Window,Worker)*/] interface ErrorEvent : Event { diff --git a/components/script/dom/webidls/HTMLCollection.webidl b/components/script/dom/webidls/HTMLCollection.webidl index 693984bcbb8..d244ba5e9b1 100644 --- a/components/script/dom/webidls/HTMLCollection.webidl +++ b/components/script/dom/webidls/HTMLCollection.webidl @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -// http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-75708506 +// https://dom.spec.whatwg.org/#interface-htmlcollection interface HTMLCollection { readonly attribute unsigned long length; diff --git a/components/script/dom/webidls/WebSocket.webidl b/components/script/dom/webidls/WebSocket.webidl index 4233a0d50b9..5870eb953be 100644 --- a/components/script/dom/webidls/WebSocket.webidl +++ b/components/script/dom/webidls/WebSocket.webidl @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -// https://w3c.github.io/websockets/#the-websocket-interface +// https://html.spec.whatwg.org/multipage/#the-websocket-interface enum BinaryType { "blob", "arraybuffer" }; diff --git a/python/tidy.py b/python/tidy.py index 6c04cc8b51b..61b2bff45c3 100644 --- a/python/tidy.py +++ b/python/tidy.py @@ -173,9 +173,7 @@ def check_webidl_spec(contents): # a_domain.path().cmp(b_domain.path()) # } standards = [ - "//w3c.github.io", "//www.khronos.org/registry/webgl/specs", - "//developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser", "//developer.mozilla.org/en-US/docs/Web/API", "//dev.w3.org/2006/webapi", "//dev.w3.org/csswg", From ce4709d6a7fdbceff5e4e9351cd11255e2fff894 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Wed, 22 Jul 2015 10:52:04 -0700 Subject: [PATCH 3/3] Remove the last few TRs. --- components/script/dom/webidls/EventListener.webidl | 6 +----- components/script/dom/webidls/EventTarget.webidl | 6 +----- components/script/dom/webidls/NodeIterator.webidl | 6 +----- python/tidy.py | 1 - 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/components/script/dom/webidls/EventListener.webidl b/components/script/dom/webidls/EventListener.webidl index 05e1684d31e..82fe3205d12 100644 --- a/components/script/dom/webidls/EventListener.webidl +++ b/components/script/dom/webidls/EventListener.webidl @@ -3,11 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. * - * The origin of this IDL file is - * http://www.w3.org/TR/2012/WD-dom-20120105/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. + * https://dom.spec.whatwg.org/#callbackdef-eventlistener */ callback interface EventListener { diff --git a/components/script/dom/webidls/EventTarget.webidl b/components/script/dom/webidls/EventTarget.webidl index 897756fa273..c5c2150574c 100644 --- a/components/script/dom/webidls/EventTarget.webidl +++ b/components/script/dom/webidls/EventTarget.webidl @@ -3,11 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. * - * The origin of this IDL file is - * http://www.w3.org/TR/2012/WD-dom-20120105/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. + * https://dom.spec.whatwg.org/#interface-eventtarget */ interface EventTarget { diff --git a/components/script/dom/webidls/NodeIterator.webidl b/components/script/dom/webidls/NodeIterator.webidl index 73a28040715..598efdbe456 100644 --- a/components/script/dom/webidls/NodeIterator.webidl +++ b/components/script/dom/webidls/NodeIterator.webidl @@ -3,11 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. * - * The origin of this IDL file is - * http://www.w3.org/TR/2012/WD-dom-20120105/ - * - * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C - * liability, trademark and document use rules apply. + * https://dom.spec.whatwg.org/#nodeiterator */ // Import from http://hg.mozilla.org/mozilla-central/raw-file/a5a720259d79/dom/webidl/NodeIterator.webidl diff --git a/python/tidy.py b/python/tidy.py index 61b2bff45c3..617caf04631 100644 --- a/python/tidy.py +++ b/python/tidy.py @@ -179,7 +179,6 @@ def check_webidl_spec(contents): "//dev.w3.org/csswg", "//dev.w3.org/fxtf", "//dvcs.w3.org/hg", - "//www.w3.org/TR", "//dom.spec.whatwg.org", "//domparsing.spec.whatwg.org", "//encoding.spec.whatwg.org",