summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornbarth@chromium.org <nbarth@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-06-23 12:31:07 +0000
committernbarth@chromium.org <nbarth@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2014-06-23 12:31:07 +0000
commit4f125edda42c9734d14b883ea008f1e7a0d60589 (patch)
tree634b29b01a5a950280d189b0e3d834ec63691ec5
parent0630a6b272cc7bd4d50b887de3dbd2dddeecc453 (diff)
downloadchromium-4f125edda42c9734d14b883ea008f1e7a0d60589.tar.gz
chromium-4f125edda42c9734d14b883ea008f1e7a0d60589.tar.bz2
chromium-4f125edda42c9734d14b883ea008f1e7a0d60589.zip
Throw TypeError when addEventListener or removeEventListener are called without enough arguments
** Changes web-facing behavior ** This removes legacy behavior, per request of Tab: it fixes some current compatibility problems which *are* causing pain, but potentially breaks some old content. Current behavior (not throwing a TypeError) was for compatibility in 2012, though unspecified cause: WebKit bug specifically special-casing this in JavaScriptCore bindings is: [JSC] Regression: addEventListener() and removeEventListener() raise an exception on missing args https://bugs.webkit.org/show_bug.cgi?id=85928 WebKit/Safari also has legacy behavior (matches current Blink/Chrome): "For compatibility with legacy content, the EventListener calls are generated without GenerateArgumentsCountCheck." http://trac.webkit.org/browser/trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm#L2823 However, IE and Firefox *do* throw (correctly), and this discrepancy is causing compatibility problems: removeEventListener with only one passed parameter... http://lists.w3.org/Archives/Public/public-script-coord/2014AprJun/0166.html Thus this CL aligns with spec, updating tests and removing legacy tests. R=haraken BUG=353484 TEST=fast/dom/event-target-arguments.html Review URL: https://codereview.chromium.org/329053002 git-svn-id: svn://svn.chromium.org/blink/trunk@176746 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--LayoutTests/fast/dom/Window/window-legacy-event-listener-expected.txt13
-rw-r--r--LayoutTests/fast/dom/Window/window-legacy-event-listener.html17
-rw-r--r--LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener-expected.txt13
-rw-r--r--LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener.html17
-rw-r--r--LayoutTests/fast/dom/event-target-arguments-expected.txt20
-rw-r--r--LayoutTests/fast/dom/event-target-arguments.html40
-rw-r--r--LayoutTests/fast/dom/node-legacy-event-listener-expected.txt13
-rw-r--r--LayoutTests/fast/dom/node-legacy-event-listener.html17
-rw-r--r--LayoutTests/fast/js/function-length-expected.txt2
-rw-r--r--LayoutTests/fast/js/function-length.html4
-rw-r--r--Source/bindings/scripts/v8_interface.py9
-rw-r--r--Source/bindings/scripts/v8_methods.py16
-rw-r--r--Source/bindings/scripts/v8_types.py4
-rw-r--r--Source/bindings/templates/interface.cpp6
-rw-r--r--Source/bindings/templates/methods.cpp2
-rw-r--r--Source/bindings/tests/idls/TestObject.idl2
-rw-r--r--Source/bindings/tests/results/V8TestObject.cpp13
-rw-r--r--Source/core/events/EventTarget.h9
-rw-r--r--Source/core/events/EventTarget.idl18
19 files changed, 63 insertions, 172 deletions
diff --git a/LayoutTests/fast/dom/Window/window-legacy-event-listener-expected.txt b/LayoutTests/fast/dom/Window/window-legacy-event-listener-expected.txt
deleted file mode 100644
index 0c0a5c23e254..000000000000
--- a/LayoutTests/fast/dom/Window/window-legacy-event-listener-expected.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Test addEventListener() and removeEventListener() fail silently if arguments are missing.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS window.addEventListener("foo") is undefined
-PASS window.removeEventListener("bar") is undefined
-PASS window.addEventListener() is undefined
-PASS window.removeEventListener() is undefined
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/dom/Window/window-legacy-event-listener.html b/LayoutTests/fast/dom/Window/window-legacy-event-listener.html
deleted file mode 100644
index 01b40fb6fee6..000000000000
--- a/LayoutTests/fast/dom/Window/window-legacy-event-listener.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../../resources/js-test.js"></script>
-</head>
-<body>
-<script>
-description("Test addEventListener() and removeEventListener() fail silently if arguments are missing.");
-
-shouldBe('window.addEventListener("foo")', 'undefined');
-shouldBe('window.removeEventListener("bar")', 'undefined');
-
-shouldBe('window.addEventListener()', 'undefined');
-shouldBe('window.removeEventListener()', 'undefined');
-</script>
-</body>
-</html>
diff --git a/LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener-expected.txt b/LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener-expected.txt
deleted file mode 100644
index 6541ac3cac34..000000000000
--- a/LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener-expected.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Test addEventListener() and removeEventListener() fail silently if arguments are missing.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS new XMLHttpRequest().addEventListener("foo") is undefined
-PASS new XMLHttpRequest().removeEventListener("bar") is undefined
-PASS new XMLHttpRequest().addEventListener() is undefined
-PASS new XMLHttpRequest().removeEventListener() is undefined
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener.html b/LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener.html
deleted file mode 100644
index 5be227731a5e..000000000000
--- a/LayoutTests/fast/dom/XMLHttpRequest-legacy-event-listener.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
-<script>
-description("Test addEventListener() and removeEventListener() fail silently if arguments are missing.");
-
-shouldBe('new XMLHttpRequest().addEventListener("foo")', 'undefined');
-shouldBe('new XMLHttpRequest().removeEventListener("bar")', 'undefined');
-
-shouldBe('new XMLHttpRequest().addEventListener()', 'undefined');
-shouldBe('new XMLHttpRequest().removeEventListener()', 'undefined');
-</script>
-</body>
-</html>
diff --git a/LayoutTests/fast/dom/event-target-arguments-expected.txt b/LayoutTests/fast/dom/event-target-arguments-expected.txt
index 46d86e5dfb07..86209f536361 100644
--- a/LayoutTests/fast/dom/event-target-arguments-expected.txt
+++ b/LayoutTests/fast/dom/event-target-arguments-expected.txt
@@ -5,37 +5,37 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Signature:
void addEventListener(DOMString type, EventListener listener, optional boolean useCapture)
-PASS document.addEventListener() is undefined
-PASS document.addEventListener("foo") is undefined
+PASS document.addEventListener() threw exception TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only 0 present..
+PASS document.addEventListener("foo") threw exception TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only 1 present..
PASS document.addEventListener("foo", listener) did not throw exception.
PASS document.addEventListener("", listener) did not throw exception.
PASS document.addEventListener("", function(){}) did not throw exception.
PASS document.addEventListener("bar", listener, false) did not throw exception.
PASS document.addEventListener("bar", listener, true) did not throw exception.
-PASS document.addEventListener(null) is undefined
+PASS document.addEventListener(null) threw exception TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only 1 present..
PASS document.addEventListener(null, listener) did not throw exception.
PASS document.addEventListener("foo", null) is undefined
PASS document.addEventListener("zork", listener, null) did not throw exception.
-PASS document.addEventListener(undefined) is undefined
-PASS document.addEventListener(undefined, listener) is undefined
+PASS document.addEventListener(undefined) threw exception TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only 1 present..
+PASS document.addEventListener(undefined, listener) did not throw exception.
PASS document.addEventListener("foo", undefined) is undefined
PASS document.addEventListener("zork", listener, undefined) did not throw exception.
Signature:
void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture)
-PASS document.removeEventListener() is undefined
-PASS document.removeEventListener("foo") is undefined
+PASS document.removeEventListener() threw exception TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 0 present..
+PASS document.removeEventListener("foo") threw exception TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present..
PASS document.removeEventListener("foo", listener) did not throw exception.
PASS document.removeEventListener("foo", listener, true) did not throw exception.
PASS document.removeEventListener("bar", listener, false) did not throw exception.
PASS document.removeEventListener("bar", listener, false) did not throw exception.
PASS document.removeEventListener("bar", listener, true) did not throw exception.
-PASS document.removeEventListener(null) is undefined
+PASS document.removeEventListener(null) threw exception TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present..
PASS document.removeEventListener(null, listener) did not throw exception.
PASS document.removeEventListener("foo", null) is undefined
PASS document.removeEventListener("zork", listener, null) did not throw exception.
-PASS document.removeEventListener(undefined) is undefined
-PASS document.removeEventListener(undefined, listener) is undefined
+PASS document.removeEventListener(undefined) threw exception TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present..
+PASS document.removeEventListener(undefined, listener) did not throw exception.
PASS document.removeEventListener("foo", undefined) is undefined
PASS document.removeEventListener("zork", listener, undefined) did not throw exception.
PASS successfullyParsed is true
diff --git a/LayoutTests/fast/dom/event-target-arguments.html b/LayoutTests/fast/dom/event-target-arguments.html
index a91793dd24b5..8698ed35cf57 100644
--- a/LayoutTests/fast/dom/event-target-arguments.html
+++ b/LayoutTests/fast/dom/event-target-arguments.html
@@ -10,62 +10,42 @@ function listener(event)
debug('Signature:')
debug('void addEventListener(DOMString type, EventListener listener, optional boolean useCapture)');
-// FIXME: should throw on missing arguments: http://crbug.com/353484
-// shouldThrow('document.addEventListener()');
-// shouldThrow('document.addEventListener("foo")');
-shouldBe('document.addEventListener()', 'undefined');
-shouldBe('document.addEventListener("foo")', 'undefined');
+shouldThrow('document.addEventListener()');
+shouldThrow('document.addEventListener("foo")');
shouldNotThrow('document.addEventListener("foo", listener)');
shouldNotThrow('document.addEventListener("", listener)');
shouldNotThrow('document.addEventListener("", function(){})');
shouldNotThrow('document.addEventListener("bar", listener, false)');
shouldNotThrow('document.addEventListener("bar", listener, true)');
// null
-shouldBe('document.addEventListener(null)', 'undefined');
+shouldThrow('document.addEventListener(null)');
shouldNotThrow('document.addEventListener(null, listener)'); // converted to "null"
-// FIXME: throw on |null|: http://crbug.com/249598
-// shouldThrow('document.addEventListener("foo", null)');
shouldBe('document.addEventListener("foo", null)', 'undefined');
shouldNotThrow('document.addEventListener("zork", listener, null)');
// undefined
-// FIXME: behavior of undefined for mandatory arguments is unclear, but
-// probably should throw
-// https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532
-shouldBe('document.addEventListener(undefined)', 'undefined');
-// shouldThrow('document.addEventListener(undefined, listener)');
-// shouldThrow('document.addEventListener("foo", undefined)');
-shouldBe('document.addEventListener(undefined, listener)', 'undefined');
+shouldThrow('document.addEventListener(undefined)');
+shouldNotThrow('document.addEventListener(undefined, listener)', 'undefined'); // converted to "undefined"
shouldBe('document.addEventListener("foo", undefined)', 'undefined');
shouldNotThrow('document.addEventListener("zork", listener, undefined)');
debug('');
debug('Signature:');
debug('void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture)');
-// FIXME: should throw on missing arguments: http://crbug.com/353484
-// shouldThrow('document.removeEventListener()');
-// shouldThrow('document.removeEventListener("foo")');
-shouldBe('document.removeEventListener()', 'undefined');
-shouldBe('document.removeEventListener("foo")', 'undefined');
+shouldThrow('document.removeEventListener()');
+shouldThrow('document.removeEventListener("foo")');
shouldNotThrow('document.removeEventListener("foo", listener)');
shouldNotThrow('document.removeEventListener("foo", listener, true)');
shouldNotThrow('document.removeEventListener("bar", listener, false)');
shouldNotThrow('document.removeEventListener("bar", listener, false)');
shouldNotThrow('document.removeEventListener("bar", listener, true)');
// null
-shouldBe('document.removeEventListener(null)', 'undefined');
+shouldThrow('document.removeEventListener(null)');
shouldNotThrow('document.removeEventListener(null, listener)'); // converted to "null"
-// FIXME: throw on |null|: http://crbug.com/249598
-// shouldThrow('document.removeEventListener("foo", null)');
shouldBe('document.removeEventListener("foo", null)', 'undefined');
shouldNotThrow('document.removeEventListener("zork", listener, null)');
// undefined
-// FIXME: behavior of undefined for mandatory arguments is unclear, but
-// probably should throw
-// https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532
-shouldBe('document.removeEventListener(undefined)', 'undefined');
-// shouldthrow('document.removeeventlistener("foo", undefined)');
-// shouldthrow('document.removeeventlistener(undefined, listener)');
-shouldBe('document.removeEventListener(undefined, listener)', 'undefined');
+shouldThrow('document.removeEventListener(undefined)');
+shouldNotThrow('document.removeEventListener(undefined, listener)', 'undefined'); // converted to "undefined"
shouldBe('document.removeEventListener("foo", undefined)', 'undefined');
shouldNotThrow('document.removeEventListener("zork", listener, undefined)');
</script>
diff --git a/LayoutTests/fast/dom/node-legacy-event-listener-expected.txt b/LayoutTests/fast/dom/node-legacy-event-listener-expected.txt
deleted file mode 100644
index dcb37d67c389..000000000000
--- a/LayoutTests/fast/dom/node-legacy-event-listener-expected.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Test addEventListener() and removeEventListener() fail silently if arguments are missing.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS document.addEventListener("foo") is undefined
-PASS document.removeEventListener("bar") is undefined
-PASS document.addEventListener() is undefined
-PASS document.removeEventListener() is undefined
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/fast/dom/node-legacy-event-listener.html b/LayoutTests/fast/dom/node-legacy-event-listener.html
deleted file mode 100644
index a5b6eaf9a370..000000000000
--- a/LayoutTests/fast/dom/node-legacy-event-listener.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
-<body>
-<script>
-description("Test addEventListener() and removeEventListener() fail silently if arguments are missing.");
-
-shouldBe('document.addEventListener("foo")', 'undefined');
-shouldBe('document.removeEventListener("bar")', 'undefined');
-
-shouldBe('document.addEventListener()', 'undefined');
-shouldBe('document.removeEventListener()', 'undefined');
-</script>
-</body>
-</html>
diff --git a/LayoutTests/fast/js/function-length-expected.txt b/LayoutTests/fast/js/function-length-expected.txt
index 0067f1342efb..90158d5fa10f 100644
--- a/LayoutTests/fast/js/function-length-expected.txt
+++ b/LayoutTests/fast/js/function-length-expected.txt
@@ -8,7 +8,7 @@ PASS window.open.length is 2
PASS window.showModalDialog.length is 1
PASS window.setTimeout.length is 1
PASS window.clearTimeout.length is 0
-PASS window.addEventListener.length is 0
+PASS window.addEventListener.length is 2
PASS window.postMessage.length is 2
PASS window.dispatchEvent.length is 1
PASS window.openDatabase.length is 4
diff --git a/LayoutTests/fast/js/function-length.html b/LayoutTests/fast/js/function-length.html
index 9109b37856d9..1aae8353a5f8 100644
--- a/LayoutTests/fast/js/function-length.html
+++ b/LayoutTests/fast/js/function-length.html
@@ -12,9 +12,7 @@ shouldBe('window.open.length', '2');
shouldBe('window.showModalDialog.length', '1');
shouldBe('window.setTimeout.length', '1');
shouldBe('window.clearTimeout.length', '0');
-// addEventListener.length should be 2, but legacy content calls with 0 or 1
-// argument. See http://crbug.com/249598
-shouldBe('window.addEventListener.length', '0');
+shouldBe('window.addEventListener.length', '2');
shouldBe('window.postMessage.length', '2');
shouldBe('window.dispatchEvent.length', '1');
shouldBe('window.openDatabase.length', '4');
diff --git a/Source/bindings/scripts/v8_interface.py b/Source/bindings/scripts/v8_interface.py
index c2719909e555..d9bd53866c9f 100644
--- a/Source/bindings/scripts/v8_interface.py
+++ b/Source/bindings/scripts/v8_interface.py
@@ -90,9 +90,10 @@ def interface_context(interface):
# [ActiveDOMObject]
is_active_dom_object = 'ActiveDOMObject' in extended_attributes
- # [CheckSecurity]
- is_check_security = 'CheckSecurity' in extended_attributes
- if is_check_security:
+ # [CheckSecurity=Frame]
+ is_check_security_for_frame = has_extended_attribute_value(
+ interface, 'CheckSecurity', 'Frame')
+ if is_check_security_for_frame:
includes.add('bindings/v8/BindingSecurity.h')
# [DependentLifetime]
@@ -151,7 +152,7 @@ def interface_context(interface):
'interface_name': interface.name,
'is_active_dom_object': is_active_dom_object,
'is_audio_buffer': is_audio_buffer,
- 'is_check_security': is_check_security,
+ 'is_check_security_for_frame': is_check_security_for_frame,
'is_dependent_lifetime': is_dependent_lifetime,
'is_document': is_document,
'is_event_target': inherits_interface(interface.name, 'EventTarget'),
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py
index fd82bad2f192..80fe8d9ecb80 100644
--- a/Source/bindings/scripts/v8_methods.py
+++ b/Source/bindings/scripts/v8_methods.py
@@ -88,10 +88,12 @@ def method_context(interface, method):
if is_call_with_script_arguments:
includes.update(['bindings/v8/ScriptCallStackFactory.h',
'core/inspector/ScriptArguments.h'])
- is_call_with_script_state = has_extended_attribute_value(method, 'CallWith', 'ScriptState')
+ is_call_with_script_state = has_extended_attribute_value(
+ method, 'CallWith', 'ScriptState')
if is_call_with_script_state:
includes.add('bindings/v8/ScriptState.h')
- is_check_security_for_node = 'CheckSecurity' in extended_attributes
+ is_check_security_for_node = has_extended_attribute_value(
+ method, 'CheckSecurity', 'Node')
if is_check_security_for_node:
includes.add('bindings/v8/BindingSecurity.h')
is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
@@ -100,9 +102,9 @@ def method_context(interface, method):
has_event_listener_argument = any(
argument for argument in arguments
- if argument.idl_type.name == 'EventListener')
+ if argument.idl_type.name == 'EventListenerOrNull')
is_check_security_for_frame = (
- 'CheckSecurity' in interface.extended_attributes and
+ has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and
'DoNotCheckSecurity' not in extended_attributes)
is_raises_exception = 'RaisesException' in extended_attributes
@@ -127,7 +129,7 @@ def method_context(interface, method):
method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
'has_event_listener_argument': has_event_listener_argument,
'has_exception_state':
- has_event_listener_argument or
+ interface.name == 'EventTarget' or # FIXME: merge with is_check_security_for_frame http://crbug.com/383699
is_raises_exception or
is_check_security_for_frame or
any(argument for argument in arguments
@@ -188,7 +190,7 @@ def argument_context(interface, method, argument, index):
'has_default': 'Default' in extended_attributes or argument.default_value,
'has_event_listener_argument': any(
argument_so_far for argument_so_far in method.arguments[:index]
- if argument_so_far.idl_type.name == 'EventListener'),
+ if argument_so_far.idl_type.name == 'EventListenerOrNull'),
'has_type_checking_interface':
(has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
@@ -222,7 +224,7 @@ def argument_context(interface, method, argument, index):
def cpp_value(interface, method, number_of_arguments):
def cpp_argument(argument):
idl_type = argument.idl_type
- if idl_type.name == 'EventListener':
+ if idl_type.name == 'EventListenerOrNull':
if (interface.name == 'EventTarget' and
method.name == 'removeEventListener'):
# FIXME: remove this special case by moving get() into
diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py
index f8c83faf67d9..9869a50cb147 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -290,9 +290,9 @@ INCLUDES_FOR_TYPE = {
'Dictionary': set(['bindings/v8/Dictionary.h']),
'EventHandler': set(['bindings/v8/V8AbstractEventListener.h',
'bindings/v8/V8EventListenerList.h']),
- 'EventListener': set(['bindings/v8/BindingSecurity.h',
+ 'EventListener': set(['bindings/v8/BindingSecurity.h', # FIXME: replace with [CheckSecurity=Frame] http://crbug.com/383699
'bindings/v8/V8EventListenerList.h',
- 'core/frame/LocalDOMWindow.h']),
+ 'core/frame/LocalDOMWindow.h']), # FIXME: move to EventTarget::frame
'HTMLCollection': set(['bindings/core/v8/V8HTMLCollection.h',
'core/dom/ClassCollection.h',
'core/dom/TagCollection.h',
diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp
index 32639ef1105f..4196d9bfea7b 100644
--- a/Source/bindings/templates/interface.cpp
+++ b/Source/bindings/templates/interface.cpp
@@ -83,7 +83,7 @@ static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop
{% if has_replaceable_attributes or has_constructor_attributes %}
static void {{cpp_class}}ForceSetAttributeOnThis(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
- {% if is_check_security %}
+ {% if is_check_security_for_frame %}
{{cpp_class}}* impl = {{v8_class}}::toNative(info.Holder());
v8::Isolate* isolate = info.GetIsolate();
v8::String::Utf8Value attributeName(name);
@@ -108,7 +108,7 @@ static void {{cpp_class}}ForceSetAttributeOnThisCallback(v8::Local<v8::String> n
{##############################################################################}
{% block security_check_functions %}
-{% if is_check_security and interface_name != 'Window' %}
+{% if is_check_security_for_frame and interface_name != 'Window' %}
bool indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t index, v8::AccessType type, v8::Local<v8::Value>)
{
{{cpp_class}}* impl = {{v8_class}}::toNative(host);
@@ -921,7 +921,7 @@ static void configure{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> funct
{% endif %}
v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
- {% if is_check_security and interface_name != 'Window' %}
+ {% if is_check_security_for_frame and interface_name != 'Window' %}
instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecurityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isolate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo)));
{% endif %}
{% for attribute in attributes
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index 4a44e7228dc0..33651722f4bc 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -21,7 +21,7 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
{% endif %}
{# Security checks #}
- {# FIXME: change to method.is_check_security_for_window #}
+ {# FIXME: merge to method.is_check_security_for_frame http://crbug.com/383699 #}
{% if interface_name == 'EventTarget' %}
if (LocalDOMWindow* window = impl->toDOMWindow()) {
if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window->frame(), exceptionState)) {
diff --git a/Source/bindings/tests/idls/TestObject.idl b/Source/bindings/tests/idls/TestObject.idl
index 8328c86d7846..e884286a062b 100644
--- a/Source/bindings/tests/idls/TestObject.idl
+++ b/Source/bindings/tests/idls/TestObject.idl
@@ -363,7 +363,7 @@ interface TestObject {
SerializedScriptValue serializedScriptValueMethod();
XPathNSResolver xPathNSResolverMethod();
void voidMethodDictionaryArg(Dictionary dictionaryArg);
- void voidMethodEventListenerArg(EventListener eventListenerArg);
+ void voidMethodEventListenerOrNullArg(EventListener? eventListenerArg);
void voidMethodNodeFilterArg(NodeFilter nodeFilterArg);
void voidMethodPromiseArg(Promise promiseArg);
void voidMethodSerializedScriptValueArg(SerializedScriptValue serializedScriptValueArg);
diff --git a/Source/bindings/tests/results/V8TestObject.cpp b/Source/bindings/tests/results/V8TestObject.cpp
index 4b312e40b928..de8701a0a63d 100644
--- a/Source/bindings/tests/results/V8TestObject.cpp
+++ b/Source/bindings/tests/results/V8TestObject.cpp
@@ -6411,11 +6411,10 @@ static void voidMethodDictionaryArgMethodCallback(const v8::FunctionCallbackInfo
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
-static void voidMethodEventListenerArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
+static void voidMethodEventListenerOrNullArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodEventListenerArg", "TestObject", info.Holder(), info.GetIsolate());
if (UNLIKELY(info.Length() < 1)) {
- throwMinimumArityTypeError(exceptionState, 1, info.Length());
+ throwMinimumArityTypeErrorForMethod("voidMethodEventListenerOrNullArg", "TestObject", 1, info.Length(), info.GetIsolate());
return;
}
TestObject* impl = V8TestObject::toNative(info.Holder());
@@ -6423,15 +6422,15 @@ static void voidMethodEventListenerArgMethod(const v8::FunctionCallbackInfo<v8::
{
eventListenerArg = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOrCreate);
}
- impl->voidMethodEventListenerArg(eventListenerArg);
+ impl->voidMethodEventListenerOrNullArg(eventListenerArg);
if (listener && !impl->toNode())
removeHiddenValueFromArray(info.Holder(), info[1], V8TestObject::eventListenerCacheIndex, info.GetIsolate());
}
-static void voidMethodEventListenerArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+static void voidMethodEventListenerOrNullArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
- TestObjectV8Internal::voidMethodEventListenerArgMethod(info);
+ TestObjectV8Internal::voidMethodEventListenerOrNullArgMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
}
@@ -9825,7 +9824,7 @@ static const V8DOMConfiguration::MethodConfiguration V8TestObjectMethods[] = {
{"serializedScriptValueMethod", TestObjectV8Internal::serializedScriptValueMethodMethodCallback, 0, 0},
{"xPathNSResolverMethod", TestObjectV8Internal::xPathNSResolverMethodMethodCallback, 0, 0},
{"voidMethodDictionaryArg", TestObjectV8Internal::voidMethodDictionaryArgMethodCallback, 0, 1},
- {"voidMethodEventListenerArg", TestObjectV8Internal::voidMethodEventListenerArgMethodCallback, 0, 1},
+ {"voidMethodEventListenerOrNullArg", TestObjectV8Internal::voidMethodEventListenerOrNullArgMethodCallback, 0, 1},
{"voidMethodNodeFilterArg", TestObjectV8Internal::voidMethodNodeFilterArgMethodCallback, 0, 1},
{"voidMethodPromiseArg", TestObjectV8Internal::voidMethodPromiseArgMethodCallback, 0, 1},
{"voidMethodSerializedScriptValueArg", TestObjectV8Internal::voidMethodSerializedScriptValueArgMethodCallback, 0, 1},
diff --git a/Source/core/events/EventTarget.h b/Source/core/events/EventTarget.h
index 2e86b3c77db0..4c3f39262706 100644
--- a/Source/core/events/EventTarget.h
+++ b/Source/core/events/EventTarget.h
@@ -86,14 +86,9 @@ public:
virtual LocalDOMWindow* toDOMWindow();
virtual MessagePort* toMessagePort();
- // FIXME: first 2 args to addEventListener and removeEventListener should
- // be required (per spec), but throwing TypeError breaks legacy content.
- // http://crbug.com/353484
- bool addEventListener() { return false; }
- bool addEventListener(const AtomicString& eventType) { return false; }
+ // FIXME: default values should be specified in IDL, not C++
+ // http://crbug.com/258153
virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture = false);
- bool removeEventListener() { return false; }
- bool removeEventListener(const AtomicString& eventType) { return false; }
virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture = false);
virtual void removeAllEventListeners();
virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>);
diff --git a/Source/core/events/EventTarget.idl b/Source/core/events/EventTarget.idl
index 69a4bc18d7b6..08329aa268ad 100644
--- a/Source/core/events/EventTarget.idl
+++ b/Source/core/events/EventTarget.idl
@@ -18,17 +18,23 @@
* Boston, MA 02110-1301, USA.
*/
+// http://dom.spec.whatwg.org/#interface-eventtarget
+
[
+ // FIXME: should use [CheckSecurity=Frame] http://crbug.com/383699
+ // CheckSecurity=Frame,
Custom=ToV8,
WillBeGarbageCollected,
] interface EventTarget {
- // FIXME: first 2 args should be required, but throwing TypeError breaks
- // legacy content. http://crbug.com/353484
- void addEventListener([TreatNullAs=NullString] optional DOMString type,
- optional EventListener listener,
+ void addEventListener([TreatNullAs=NullString] DOMString type,
+ EventListener? listener,
+ // FIXME: should be useCapture = false
+ // http://crbug.com/258153
optional boolean useCapture);
- void removeEventListener([TreatNullAs=NullString] optional DOMString type,
- optional EventListener listener,
+ void removeEventListener([TreatNullAs=NullString] DOMString type,
+ EventListener? listener,
+ // FIXME: should be useCapture = false
+ // http://crbug.com/258153
optional boolean useCapture);
[RaisesException] boolean dispatchEvent(Event event);
};