Bug 1520756 - Disable Window.event, Event.returnValue and setting keyCode and charCode of "keypress" events to same value. r=smaug, a=RyanVM
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 16 Jan 2019 20:47:09 +0900
changeset 509531 6881825b5cd71efff043f4dbb0e56339e93b3ad7
parent 509530 21ebd471d7a645f5b501abbb194f4696195dae63
child 509532 1790d083bb5766db07a44f891bf786173d60da02
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, RyanVM
bugs1520756, 1496288, 1479964, 1478102
milestone65.0
Bug 1520756 - Disable Window.event, Event.returnValue and setting keyCode and charCode of "keypress" events to same value. r=smaug, a=RyanVM In bug 1496288, we decided to ship the following new features: - Windows.event - Setting keyCode and charCode of "keypress" events to same value - Stop dispatching non-printable "keypress" events - Start to dispatch "keydown" and "keyup" events even during composition However, the 2nd change breaks editor of Confluence. For making the shipment of 65 safer, we should cancel shipping the 2nd change. Then, we need to disable Window.event and Event.returnValue too because they are blocked by the 2nd (bug 1479964 and bug 1478102). On the other hand, perhaps, we should ship the last 2 changes as planned because web apps cannot detect these changes from any API and also we've already introduced these changes. So, some web apps have already started to check version number of Firefox. We shouldn't break such web apps.
dom/base/DOMPrefsInternal.h
dom/webidl/Event.webidl
modules/libpref/init/StaticPrefList.h
modules/libpref/init/all.js
testing/web-platform/meta/dom/events/AddEventListenerOptions-passive.html.ini
testing/web-platform/meta/dom/events/Event-constructors.html.ini
testing/web-platform/meta/dom/events/Event-defaultPrevented-after-dispatch.html.ini
testing/web-platform/meta/dom/events/Event-defaultPrevented.html.ini
testing/web-platform/meta/dom/events/Event-initEvent.html.ini
testing/web-platform/meta/dom/events/Event-returnValue.html.ini
testing/web-platform/meta/dom/events/EventTarget-dispatchEvent-returnvalue.html.ini
testing/web-platform/meta/dom/interfaces.html.ini
--- a/dom/base/DOMPrefsInternal.h
+++ b/dom/base/DOMPrefsInternal.h
@@ -10,16 +10,17 @@
 //
 //   DOM_WEBIDL_PREF(foo_bar)
 //
 //   * This defines DOMPrefs::foo_bar(JSContext* aCx, JSObject* aObj) which
 //     returns the value of StaticPrefs::foo_bar().
 //     This is allows the use of DOMPrefs in WebIDL files.
 
 DOM_WEBIDL_PREF(dom_caches_enabled)
+DOM_WEBIDL_PREF(dom_event_returnValue_enabled)
 DOM_WEBIDL_PREF(dom_webnotifications_serviceworker_enabled)
 DOM_WEBIDL_PREF(dom_webnotifications_requireinteraction_enabled)
 DOM_WEBIDL_PREF(dom_serviceWorkers_enabled)
 DOM_WEBIDL_PREF(dom_storageManager_enabled)
 DOM_WEBIDL_PREF(dom_testing_structuredclonetester_enabled)
 DOM_WEBIDL_PREF(dom_promise_rejection_events_enabled)
 DOM_WEBIDL_PREF(dom_push_enabled)
 DOM_WEBIDL_PREF(gfx_offscreencanvas_enabled)
--- a/dom/webidl/Event.webidl
+++ b/dom/webidl/Event.webidl
@@ -31,17 +31,18 @@ interface Event {
 
   void stopPropagation();
   void stopImmediatePropagation();
 
   [Pure]
   readonly attribute boolean bubbles;
   [Pure]
   readonly attribute boolean cancelable;
-  [NeedsCallerType]
+  [NeedsCallerType,
+   Func="mozilla::dom::DOMPrefs::dom_event_returnValue_enabled"]
   attribute boolean returnValue;
   [NeedsCallerType]
   void preventDefault();
   [Pure, NeedsCallerType]
   readonly attribute boolean defaultPrevented;
   [ChromeOnly, Pure]
   readonly attribute boolean defaultPreventedByChrome;
   [ChromeOnly, Pure]
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -174,16 +174,23 @@ VARCACHE_PREF(
 #endif
 VARCACHE_PREF(
   "dom.animations-api.timelines.enabled",
    dom_animations_api_timelines_enabled,
   bool, PREF_VALUE
 )
 #undef PREF_VALUE
 
+// If this is true, event.returnValue is available.
+VARCACHE_PREF(
+  "dom.event.returnValue.enabled",
+   dom_event_returnValue_enabled,
+  RelaxedAtomicBool, false
+)
+
 // Whehter Mozilla specific "text" event should be dispatched only in the
 // system group or not in content.
 VARCACHE_PREF(
   "dom.compositionevent.text.dispatch_only_system_group_in_content",
    dom_compositionevent_text_dispatch_only_system_group_in_content,
    bool, true
 )
 
@@ -203,17 +210,17 @@ VARCACHE_PREF(
 )
 #undef PREF_VALUE
 
 // If this is true, "keypress" event's keyCode value and charCode value always
 // become same if the event is not created/initialized by JS.
 VARCACHE_PREF(
   "dom.keyboardevent.keypress.set_keycode_and_charcode_to_same_value",
    dom_keyboardevent_keypress_set_keycode_and_charcode_to_same_value,
-  bool, true
+  bool, false
 )
 
 // NOTE: This preference is used in unit tests. If it is removed or its default
 // value changes, please update test_sharedMap_var_caches.js accordingly.
 VARCACHE_PREF(
   "dom.webcomponents.shadowdom.report_usage",
    dom_webcomponents_shadowdom_report_usage,
   bool, false
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -259,17 +259,17 @@ pref("dom.script_loader.bytecode_cache.e
 // look at: ScriptLoader::ShouldCacheBytecode function.
 pref("dom.script_loader.bytecode_cache.strategy", 0);
 
 #ifdef JS_BUILD_BINAST
 pref("dom.script_loader.binast_encoding.enabled", false);
 #endif
 
 // Whether window.event is enabled
-pref("dom.window.event.enabled", true);
+pref("dom.window.event.enabled", false);
 
 // Fastback caching - if this pref is negative, then we calculate the number
 // of content viewers to cache based on the amount of available memory.
 pref("browser.sessionhistory.max_total_viewers", -1);
 
 pref("ui.use_native_colors", true);
 pref("ui.click_hold_context_menus", false);
 
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/dom/events/AddEventListenerOptions-passive.html.ini
@@ -0,0 +1,4 @@
+[AddEventListenerOptions-passive.html]
+  [returnValue should be ignored if-and-only-if the passive option is true]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/dom/events/Event-constructors.html.ini
@@ -0,0 +1,7 @@
+[Event-constructors.html]
+  [Event constructors 2]
+    expected: FAIL
+
+  [Event constructors 3]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/dom/events/Event-defaultPrevented-after-dispatch.html.ini
@@ -0,0 +1,4 @@
+[Event-defaultPrevented-after-dispatch.html]
+  [Default prevention via returnValue]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/dom/events/Event-defaultPrevented.html.ini
@@ -0,0 +1,4 @@
+[Event-defaultPrevented.html]
+  [returnValue should change defaultPrevented if cancelable is true.]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/dom/events/Event-initEvent.html.ini
@@ -0,0 +1,13 @@
+[Event-initEvent.html]
+  [Properties of initEvent(type, true, true)]
+    expected: FAIL
+
+  [Properties of initEvent(type, true, false)]
+    expected: FAIL
+
+  [Properties of initEvent(type, false, true)]
+    expected: FAIL
+
+  [Properties of initEvent(type, false, false)]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/dom/events/Event-returnValue.html.ini
@@ -0,0 +1,19 @@
+[Event-returnValue.html]
+  [When an event is created, returnValue should be initialized to true.]
+    expected: FAIL
+
+  [preventDefault() should not change returnValue if cancelable is false.]
+    expected: FAIL
+
+  [returnValue=false should have no effect if cancelable is false.]
+    expected: FAIL
+
+  [preventDefault() should change returnValue if cancelable is true.]
+    expected: FAIL
+
+  [initEvent should unset returnValue.]
+    expected: FAIL
+
+  [returnValue=true should have no effect once the canceled flag was set.]
+    expected: FAIL
+
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/dom/events/EventTarget-dispatchEvent-returnvalue.html.ini
@@ -0,0 +1,7 @@
+[EventTarget-dispatchEvent-returnvalue.html]
+  [Return value of EventTarget.dispatchEvent() affected by preventDefault().]
+    expected: FAIL
+
+  [Return value of EventTarget.dispatchEvent() affected by returnValue.]
+    expected: FAIL
+
--- a/testing/web-platform/meta/dom/interfaces.html.ini
+++ b/testing/web-platform/meta/dom/interfaces.html.ini
@@ -81,31 +81,55 @@
     expected: FAIL
 
   [Range interface: existence and properties of interface object]
     expected: FAIL
 
   [Range interface: existence and properties of interface prototype object]
     expected: FAIL
 
+  [Event interface: attribute returnValue]
+    expected: FAIL
+
+  [Event interface: document.createEvent("Event") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
+  [Event interface: new Event("foo") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
+  [Event interface: new CustomEvent("foo") must inherit property "returnValue" with the proper type]
+    expected: FAIL
 
 [interfaces.html?1-1000]
   [Test driver]
     expected: FAIL
 
 
 [interfaces.html?1001-last]
   [Test driver]
     expected: FAIL
 
 
 [interfaces.html?exclude=Node]
   [Test driver]
     expected: FAIL
 
+[interfaces.html?exclude=Node]
+  [Event interface: attribute returnValue]
+    expected: FAIL
+
+  [Event interface: document.createEvent("Event") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
+  [Event interface: new Event("foo") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
+  [Event interface: new CustomEvent("foo") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
   [Document interface: attribute origin]
     expected: FAIL
 
   [Document interface: new Document() must inherit property "origin" with the proper type]
     expected: FAIL
 
   [Document interface: xmlDoc must inherit property "origin" with the proper type]
     expected: FAIL
@@ -167,16 +191,28 @@
   [Range interface: existence and properties of interface prototype object]
     expected: FAIL
 
 
 [interfaces.html?include=Node]
 
 [interfaces.html?exclude=Node]
   prefs: [dom.window.event.enabled:true]
+  [Event interface: attribute returnValue]
+    expected: FAIL
+
+  [Event interface: document.createEvent("Event") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
+  [Event interface: new Event("foo") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
+  [Event interface: new CustomEvent("foo") must inherit property "returnValue" with the proper type]
+    expected: FAIL
+
   [Document interface: attribute origin]
     expected: FAIL
 
   [Document interface: new Document() must inherit property "origin" with the proper type]
     expected: FAIL
 
   [Document interface: xmlDoc must inherit property "origin" with the proper type]
     expected: FAIL