Bug 869014. Don't allow name collisions between external interfaces and other objects. r=khuey

This commit is contained in:
Boris Zbarsky 2013-05-09 13:08:29 -04:00
Родитель 546d9f565d
Коммит e335c1f797
16 изменённых файлов: 53 добавлений и 30 удалений

Просмотреть файл

@ -3396,8 +3396,15 @@ class Parser(Tokenizer):
try: try:
if self.globalScope()._lookupIdentifier(identifier): if self.globalScope()._lookupIdentifier(identifier):
p[0] = self.globalScope()._lookupIdentifier(identifier) p[0] = self.globalScope()._lookupIdentifier(identifier)
if not isinstance(p[0], IDLExternalInterface):
raise WebIDLError("Name collision between external "
"interface declaration for identifier "
"%s and %s" % (identifier.name, p[0]),
[location, p[0].location])
return return
except: except Exception, ex:
if isinstance(ex, WebIDLError):
raise ex
pass pass
p[0] = IDLExternalInterface(location, self.globalScope(), identifier) p[0] = IDLExternalInterface(location, self.globalScope(), identifier)

Просмотреть файл

@ -317,6 +317,49 @@ def WebIDLTest(parser, harness):
"Should not allow a name collision between interface " "Should not allow a name collision between interface "
"and other object") "and other object")
parser = parser.reset()
threw = False
try:
parser.parse("""
dictionary A {
boolean x;
};
interface A;
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow a name collision between external interface "
"and other object")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface A {
readonly attribute boolean x;
};
interface A;
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow a name collision between external interface "
"and interface")
parser = parser.reset()
parser.parse("""
interface A;
interface A;
""")
results = parser.finish()
harness.ok(len(results) == 1 and
isinstance(results[0], WebIDL.IDLExternalInterface),
"Should allow name collisions between external interface "
"declarations")
parser = parser.reset() parser = parser.reset()
threw = False threw = False
try: try:

Просмотреть файл

@ -4,8 +4,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. * You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
interface ClientRect;
interface ClientRectList { interface ClientRectList {
readonly attribute unsigned long length; readonly attribute unsigned long length;
getter ClientRect? item(unsigned long index); getter ClientRect? item(unsigned long index);

Просмотреть файл

@ -15,7 +15,6 @@
* http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl * http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
*/ */
interface Comment;
interface StyleSheetList; interface StyleSheetList;
interface TouchList; interface TouchList;
interface WindowProxy; interface WindowProxy;

Просмотреть файл

@ -1,8 +1,8 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface DOMRequest;
interface LockedFile; interface LockedFile;
enum FileMode { "readonly", "readwrite" }; enum FileMode { "readonly", "readwrite" };

Просмотреть файл

@ -10,8 +10,6 @@
* liability, trademark and document use rules apply. * liability, trademark and document use rules apply.
*/ */
interface Element;
interface HTMLCollection { interface HTMLCollection {
readonly attribute unsigned long length; readonly attribute unsigned long length;
getter Element? item(unsigned long index); getter Element? item(unsigned long index);

Просмотреть файл

@ -12,8 +12,6 @@
* and create derivative works of this document. * and create derivative works of this document.
*/ */
interface DOMStringMap;
interface HTMLElement : Element { interface HTMLElement : Element {
// metadata attributes // metadata attributes
attribute DOMString title; attribute DOMString title;

Просмотреть файл

@ -10,8 +10,6 @@
* liability, trademark and document use rules apply. * liability, trademark and document use rules apply.
*/ */
interface HTMLOptionElement;
interface HTMLOptionsCollection : HTMLCollection { interface HTMLOptionsCollection : HTMLCollection {
attribute unsigned long length; attribute unsigned long length;
[Throws] [Throws]

Просмотреть файл

@ -3,8 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface Attr;
/** /**
* This is a temporary, non-standard interface, to ease the transition to a * This is a temporary, non-standard interface, to ease the transition to a
* world where Attr no longer inherits from Node. * world where Attr no longer inherits from Node.

Просмотреть файл

@ -3,8 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
interface ClientRect;
/** /**
* These objects are exposed by the MozDOMAfterPaint event. Each one represents * These objects are exposed by the MozDOMAfterPaint event. Each one represents
* a request to repaint a rectangle that was generated by the browser. * a request to repaint a rectangle that was generated by the browser.

Просмотреть файл

@ -12,8 +12,6 @@
* liability, trademark and document use rules apply. * liability, trademark and document use rules apply.
*/ */
interface ClientRect;
interface Range { interface Range {
[Throws] [Throws]
readonly attribute Node startContainer; readonly attribute Node startContainer;

Просмотреть файл

@ -11,7 +11,6 @@
*/ */
interface SVGAnimatedEnumeration; interface SVGAnimatedEnumeration;
interface SVGAnimatedLength;
interface SVGMaskElement : SVGElement { interface SVGMaskElement : SVGElement {

Просмотреть файл

@ -12,7 +12,6 @@
interface SVGAnimatedString; interface SVGAnimatedString;
interface SVGViewSpec; interface SVGViewSpec;
interface SVGPoint;
interface SVGSVGElement : SVGGraphicsElement { interface SVGSVGElement : SVGGraphicsElement {

Просмотреть файл

@ -1,3 +1,4 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. * You can obtain one at http://mozilla.org/MPL/2.0/.
@ -9,8 +10,6 @@
* liability, trademark and document use rules apply. * liability, trademark and document use rules apply.
*/ */
interface DocumentFragment;
callback LifecycleCreatedCallback = void(); callback LifecycleCreatedCallback = void();
dictionary LifecycleCallbacks { dictionary LifecycleCallbacks {

Просмотреть файл

@ -15,13 +15,6 @@
// This IDL depends on the typed array specification defined at: // This IDL depends on the typed array specification defined at:
// https://www.khronos.org/registry/typedarray/specs/latest/typedarrays.idl // https://www.khronos.org/registry/typedarray/specs/latest/typedarrays.idl
// XXXbz all sorts of forward declarations for things that are not new
// bindings yet.
interface Event;
interface HTMLCanvasElement;
interface HTMLVideoElement;
interface ImageData;
typedef unsigned long GLenum; typedef unsigned long GLenum;
typedef boolean GLboolean; typedef boolean GLboolean;
typedef unsigned long GLbitfield; typedef unsigned long GLbitfield;

Просмотреть файл

@ -4,8 +4,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. * You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
interface StyleSheet;
interface XMLStylesheetProcessingInstruction : ProcessingInstruction { interface XMLStylesheetProcessingInstruction : ProcessingInstruction {
readonly attribute StyleSheet? sheet; readonly attribute StyleSheet? sheet;
}; };