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:
if 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
except:
except Exception, ex:
if isinstance(ex, WebIDLError):
raise ex
pass
p[0] = IDLExternalInterface(location, self.globalScope(), identifier)

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

@ -317,6 +317,49 @@ def WebIDLTest(parser, harness):
"Should not allow a name collision between interface "
"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()
threw = False
try:

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

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

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

@ -15,7 +15,6 @@
* http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
*/
interface Comment;
interface StyleSheetList;
interface TouchList;
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
* 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/. */
interface DOMRequest;
interface LockedFile;
enum FileMode { "readonly", "readwrite" };

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

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

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

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

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

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

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

@ -3,8 +3,6 @@
* 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/. */
interface Attr;
/**
* This is a temporary, non-standard interface, to ease the transition to a
* 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
* 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
* a request to repaint a rectangle that was generated by the browser.

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

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

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

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

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

@ -12,7 +12,6 @@
interface SVGAnimatedString;
interface SVGViewSpec;
interface SVGPoint;
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
* 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/.
@ -9,8 +10,6 @@
* liability, trademark and document use rules apply.
*/
interface DocumentFragment;
callback LifecycleCreatedCallback = void();
dictionary LifecycleCallbacks {

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

@ -15,13 +15,6 @@
// This IDL depends on the typed array specification defined at:
// 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 boolean GLboolean;
typedef unsigned long GLbitfield;

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

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