Bug 1299453 - Stop using createEvent("DragEvents"/"KeyEvents") internally; r=smaug

They are non-standard aliases for "DragEvent" and "KeyboardEvent" that
are not supported by any other UA, and we would like to drop support.
So first let's stop using them ourselves, so we can use telemetry to see
if any sites are using them.

MozReview-Commit-ID: ICC33ORa2st
This commit is contained in:
Aryeh Gregor 2016-08-31 16:24:40 +03:00
parent ff780d017f
commit 76862dadad
29 changed files with 42 additions and 42 deletions

View File

@ -221,7 +221,7 @@ var gDropTargetShim = {
*/
_dispatchEvent: function (aEvent, aType, aTarget) {
let node = aTarget.node;
let event = document.createEvent("DragEvents");
let event = document.createEvent("DragEvent");
// The event should not bubble to prevent recursion.
event.initDragEvent(aType, false, true, window, 0, 0, 0, 0, 0, false, false,

View File

@ -19,7 +19,7 @@ add_task(function* () {
function sendDragEvent(aEventType, aTarget) {
let dataTransfer = new content.DataTransfer(aEventType, false);
let event = content.document.createEvent("DragEvents");
let event = content.document.createEvent("DragEvent");
event.initDragEvent(aEventType, true, true, content, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);
aTarget.dispatchEvent(event);

View File

@ -12,7 +12,7 @@ add_task(function* () {
return ContentTask.spawn(gBrowser.selectedBrowser, { data: data }, function*(args) {
let dataTransfer = new content.DataTransfer("dragstart", false);
dataTransfer.mozSetDataAt("text/x-moz-url", args.data, 0);
let event = content.document.createEvent("DragEvents");
let event = content.document.createEvent("DragEvent");
event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);

View File

@ -15,7 +15,7 @@ add_task(function* () {
function sendDropEvent(aCellIndex, aDragData) {
let dataTransfer = new content.DataTransfer("dragstart", false);
dataTransfer.mozSetDataAt("text/x-moz-url", aDragData, 0);
let event = content.document.createEvent("DragEvents");
let event = content.document.createEvent("DragEvent");
event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);

View File

@ -78,14 +78,14 @@ function doDragEvent(sourceIndex, dropIndex) {
return ContentTask.spawn(gBrowser.selectedBrowser,
{ sourceIndex: sourceIndex, dropIndex: dropIndex }, function*(args) {
let dataTransfer = new content.DataTransfer("dragstart", false);
let event = content.document.createEvent("DragEvents");
let event = content.document.createEvent("DragEvent");
event.initDragEvent("dragstart", true, true, content, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);
let target = content.gGrid.cells[args.sourceIndex].site.node;
target.dispatchEvent(event);
event = content.document.createEvent("DragEvents");
event = content.document.createEvent("DragEvent");
event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);

View File

@ -418,7 +418,7 @@ function* simulateExternalDrop(aDestIndex) {
let dataTransfer = new iframe.contentWindow.DataTransfer("dragstart", false);
dataTransfer.mozSetDataAt("text/x-moz-url", "http://example99.com/", 0);
let event = content.document.createEvent("DragEvents");
let event = content.document.createEvent("DragEvent");
event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);

View File

@ -23,7 +23,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=456273
/** Test for Bug 456273 **/
function doTest() {
var ev = document.createEvent('KeyEvents');
var ev = document.createEvent('KeyboardEvent');
ev.initKeyEvent("keypress", true, true, null, true, false,
false, false, 0, "z".charCodeAt(0));
SpecialPowers.dispatchEvent(window, document.getElementById('edit456273'), ev);

View File

@ -39,7 +39,7 @@ function fireDrop(element, shouldAllowDrop, shouldAllowOnlyChromeDrop) {
ds.startDragSession();
var event = document.createEvent("DragEvents");
var event = document.createEvent("DragEvent");
event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, dataTransfer);
fireEvent(element, event);
@ -47,7 +47,7 @@ function fireDrop(element, shouldAllowDrop, shouldAllowOnlyChromeDrop) {
is(ds.getCurrentSession().onlyChromeDrop, shouldAllowOnlyChromeDrop,
"Unexpected .onlyChromeDrop");
event = document.createEvent("DragEvents");
event = document.createEvent("DragEvent");
event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, dataTransfer);
fireEvent(element, event);

View File

@ -60,7 +60,7 @@ function RunTest() {
window.removeEventListener("dragstart", trapDrag, true);
synthesizeMouse(image, 20, 20, { type: "mouseup" });
var event = document.createEvent("DragEvents");
var event = document.createEvent("DragEvent");
event.initDragEvent("dragover", true, true, iBox.ownerDocument.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, iBox, dataTransfer);
fireEvent(iBox, event);
synthesizeMouse(image, 3, 3, { type: "mousedown" });

View File

@ -42,22 +42,22 @@ function testInitializingUntrustedEvent()
ctrlKey: false, altKey: false, shiftKey: true, metaKey: false,
keyCode: 0x30, charCode: 0x40 },
{ createEventArg: "KeyEvents",
{ createEventArg: "KeyBoardEvent",
type: "foo", bubbles: true, cancelable: true, view: null,
ctrlKey: false, altKey: false, shiftKey: false, metaKey: true,
keyCode: 0x00, charCode: 0x50 },
{ createEventArg: "keyevents",
{ createEventArg: "keyboardevEnt",
type: "bar", bubbles: false, cancelable: true, view: window,
ctrlKey: true, altKey: true, shiftKey: false, metaKey: false,
keyCode: 0x00, charCode: 0x60 },
{ createEventArg: "Keyevents",
{ createEventArg: "KeyboaRdevent",
type: "keydown", bubbles: true, cancelable: false, view: null,
ctrlKey: false, altKey: true, shiftKey: false, metaKey: true,
keyCode: 0x30, charCode: 0x00 },
{ createEventArg: "keyEvents",
{ createEventArg: "KEYBOARDEVENT",
type: "keyup", bubbles: false, cancelable: false, view: window,
ctrlKey: true, altKey: false, shiftKey: true, metaKey: false,
keyCode: 0x10, charCode: 0x80 },

View File

@ -57,8 +57,8 @@ function afterDragTests()
false, true, false, false, 0, null, null);
$("synthetic").dispatchEvent(evt);
var evt = document.createEvent("dragevents");
ok(evt instanceof DragEvent, "synthetic dragevents class")
var evt = document.createEvent("dragevent");
ok(evt instanceof DragEvent, "synthetic dragevent class")
evt.initDragEvent("dragover", true, true, window, 0, 40, 35, 20, 15,
true, false, true, true, 2, document.documentElement, null);
$("synthetic2").dispatchEvent(evt);

View File

@ -9,19 +9,19 @@ window.addEventListener("Test:DispatchKeyEvents", aEvent => {
var keyCode = KeyEvent["DOM_" + aEvent.detail.code];
document.body.focus();
var evt = document.createEvent("KeyEvents");
var evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent("keydown", true, true, window,
false, false, false, false,
keyCode, 0);
document.body.dispatchEvent(evt);
evt = document.createEvent("KeyEvents");
evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent("keypress", true, true, window,
false, false, false, false,
keyCode, 0);
document.body.dispatchEvent(evt);
evt = document.createEvent("KeyEvents");
evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent("keyup", true, true, window,
false, false, false, false,
keyCode, 0);

View File

@ -63,7 +63,7 @@ Event.simulateKey = function(element, eventName) {
charCode: 0
}, arguments[2] || {});
var oEvent = document.createEvent("KeyEvents");
var oEvent = document.createEvent("KeyboardEvent");
oEvent.initKeyEvent(eventName, true, true, window,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
options.keyCode, options.charCode );

View File

@ -54,7 +54,7 @@ Event.simulateKey = function(element, eventName) {
charCode: 0
}, arguments[2] || {});
var oEvent = document.createEvent("KeyEvents");
var oEvent = document.createEvent("KeyboardEvent");
oEvent.initKeyEvent(eventName, true, true, window,
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
options.keyCode, options.charCode );

View File

@ -30,7 +30,7 @@ function start()
function dispatch(eventName)
{
var event = document.createEvent("DragEvents");
var event = document.createEvent("DragEvent");
event.initDragEvent(eventName, true, true, window, 0, 5, 5, 5, 5,
false, false, false, false, 0, null, null);
element.dispatchEvent(event);

View File

@ -165,7 +165,7 @@ function runTests()
var targetDescription = " (dispatched to " + aTarget._description + ")";
function dispatchKeyEvent(aKeyCode, aChar, aTarget)
{
var keyEvent = document.createEvent("KeyEvents");
var keyEvent = document.createEvent("KeyboardEvent");
keyEvent.initKeyEvent("keypress", true, true, null, false, false,
false, false, aKeyCode,
aChar ? aChar.charCodeAt(0) : 0);

View File

@ -58,11 +58,11 @@ function fireDrop(element) {
ds.startDragSession();
var event = document.createEvent("DragEvents");
var event = document.createEvent("DragEvent");
event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
fireEvent(element, event);
event = document.createEvent("DragEvents");
event = document.createEvent("DragEvent");
event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
fireEvent(element, event);

View File

@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=381167
SimpleTest.waitForExplicitFinish();
function closeit() {
var evt = document.createEvent('KeyEvents');
var evt = document.createEvent('KeyboardEvent');
evt.initKeyEvent('keypress', true, true,
window,
true, false, false, false,

View File

@ -218,7 +218,7 @@ MozMillElement.prototype.dragToElement = function(aElement, aOffsetX, aOffsetY,
EventUtils.synthesizeMouse(destNode, destCoords.x, destCoords.y,
{ type: "mousemove" }, destWindow);
var event = destWindow.document.createEvent("DragEvents");
var event = destWindow.document.createEvent("DragEvent");
event.initDragEvent("dragenter", true, true, destWindow, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);
event.initDragEvent("dragover", true, true, destWindow, 0, 0, 0, 0, 0,

View File

@ -79,7 +79,7 @@ find-menu appears in editor element which has had makeEditable() called but desi
function* enterStringIntoEditor(aString) {
for (let i = 0; i < aString.length; i++) {
yield ContentTask.spawn(gBrowser, { charCode: aString.charCodeAt(i) }, function* (args) {
let event = content.document.createEvent("KeyEvents");
let event = content.document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, args.charCode);
content.document.body.dispatchEvent(event);

View File

@ -78,7 +78,7 @@
function* enterStringIntoFindField(aString) {
for (let i = 0; i < aString.length; i++) {
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
let promise = new Promise(resolve => {
let listener = {
onFindResult: function() {

View File

@ -105,7 +105,7 @@
function promiseEnterStringIntoFindField(str) {
let promise = promiseFindResult(str);
for (let i = 0; i < str.length; i++) {
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);

View File

@ -38,7 +38,7 @@
function enterStringIntoFindField(aString) {
for (var i=0; i < aString.length; i++) {
var event = document.createEvent("KeyEvents");
var event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, aString.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);
@ -64,7 +64,7 @@
highlight.click();
// Delete search term
var event = document.createEvent("KeyEvents");
var event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, KeyEvent.DOM_VK_BACK_SPACE, 0);
gFindBar._findField.inputField.dispatchEvent(event);

View File

@ -154,7 +154,7 @@
if (waitForResult) {
promise = promiseFindResult();
}
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);
@ -248,7 +248,7 @@
function* testQuickfind(tests) {
yield ContentTask.spawn(gBrowser, null, function* () {
let document = content.document;
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, "/".charCodeAt(0));
document.documentElement.dispatchEvent(event);

View File

@ -111,7 +111,7 @@
let promise = once(gFindBar, "find");
// Put some text in the find box.
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, query.charCodeAt(0));
gFindBar._findField.inputField.dispatchEvent(event);

View File

@ -258,7 +258,7 @@
if (waitForResult) {
promise = promiseFindResult();
}
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);
@ -405,7 +405,7 @@
yield ContentTask.spawn(gBrowser, null, function* () {
let document = content.document;
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, "'".charCodeAt(0));
document.documentElement.dispatchEvent(event);
@ -487,7 +487,7 @@
yield ContentTask.spawn(gBrowser, null, function* () {
let document = content.document;
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, "/".charCodeAt(0));
document.documentElement.dispatchEvent(event);

View File

@ -50,7 +50,7 @@ function doDropAndStopLoad(browser, data, shouldExpectStateChange) {
let dataTransfer = new content.DataTransfer("dragstart", false);
dataTransfer.mozSetDataAt(data.type, data.data, 0);
let event = content.document.createEvent("DragEvents");
let event = content.document.createEvent("DragEvent");
event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);
content.document.body.dispatchEvent(event);

View File

@ -787,7 +787,7 @@
if (!aTarget)
return;
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent(aEvent.type, aEvent.bubbles, aEvent.cancelable,
aEvent.view, aEvent.ctrlKey, aEvent.altKey,
aEvent.shiftKey, aEvent.metaKey, aEvent.keyCode,

View File

@ -46,7 +46,7 @@ function promiseFindResult(findbar, str = null) {
function promiseEnterStringIntoFindField(findbar, str) {
let promise = promiseFindResult(findbar, str);
for (let i = 0; i < str.length; i++) {
let event = document.createEvent("KeyEvents");
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
findbar._findField.inputField.dispatchEvent(event);