Skip to content

Commit

Permalink
Bug 1656291 - Enable all ESLint rules for some more xhtml files in to…
Browse files Browse the repository at this point in the history
…olkit/content/tests/chrome/. r=Standard8

Depends on D86483

Differential Revision: https://phabricator.services.mozilla.com/D87183
  • Loading branch information
soniasingla committed Sep 4, 2020
1 parent 0b6d969 commit 8b80449
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 189 deletions.
26 changes: 0 additions & 26 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,32 +564,6 @@ module.exports = {
},
{
files: [
"toolkit/content/tests/chrome/frame_popup_anchor.xhtml",
"toolkit/content/tests/chrome/frame_subframe_origin_subframe1.xhtml",
"toolkit/content/tests/chrome/frame_subframe_origin_subframe2.xhtml",
"toolkit/content/tests/chrome/test_arrowpanel.xhtml",
"toolkit/content/tests/chrome/test_autocomplete2.xhtml",
"toolkit/content/tests/chrome/test_autocomplete3.xhtml",
"toolkit/content/tests/chrome/test_autocomplete4.xhtml",
"toolkit/content/tests/chrome/test_autocomplete5.xhtml",
"toolkit/content/tests/chrome/test_autocomplete_emphasis.xhtml",
"toolkit/content/tests/chrome/test_autocomplete_mac_caret.xhtml",
"toolkit/content/tests/chrome/test_autocomplete_placehold_last_complete.xhtml",
"toolkit/content/tests/chrome/test_browser_drop.xhtml",
"toolkit/content/tests/chrome/test_bug1048178.xhtml",
"toolkit/content/tests/chrome/test_bug382990.xhtml",
"toolkit/content/tests/chrome/test_bug437844.xhtml",
"toolkit/content/tests/chrome/test_bug624329.xhtml",
"toolkit/content/tests/chrome/test_bug792324.xhtml",
"toolkit/content/tests/chrome/test_contextmenu_list.xhtml",
"toolkit/content/tests/chrome/test_cursorsnap.xhtml",
"toolkit/content/tests/chrome/test_dialogfocus.xhtml",
"toolkit/content/tests/chrome/test_hiddenitems.xhtml",
"toolkit/content/tests/chrome/test_hiddenpaging.xhtml",
"toolkit/content/tests/chrome/test_maximized_persist.xhtml",
"toolkit/content/tests/chrome/test_menu.xhtml",
"toolkit/content/tests/chrome/test_menuitem_blink.xhtml",
"toolkit/content/tests/chrome/test_menulist.xhtml",
"toolkit/content/tests/chrome/test_menulist_keynav.xhtml",
"toolkit/content/tests/chrome/test_mousescroll.xhtml",
"toolkit/content/tests/chrome/test_mozinputbox_dictionary.xhtml",
Expand Down
6 changes: 3 additions & 3 deletions toolkit/content/tests/chrome/frame_popup_anchor.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ function popupShown()
var left, top;
var popuprect = document.getElementById("popup").getBoundingClientRect();
if (isSecondTest) {
var buttonrect = document.getElementById("button").getBoundingClientRect();
let buttonrect = document.getElementById("button").getBoundingClientRect();
left = buttonrect.left + 6;
top = buttonrect.top + 6;
}
else {
var iframerect = parent.document.getElementById("frame").getBoundingClientRect();
var buttonrect = parent.document.getElementById("outerbutton").getBoundingClientRect();
let iframerect = parent.document.getElementById("frame").getBoundingClientRect();
let buttonrect = parent.document.getElementById("outerbutton").getBoundingClientRect();

// The popup should appear anchored on the bottom left edge of the button, however
// the client rectangle is relative to the iframe's document. Thus the coordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function runTests()

function mouseMove(e) {
e.stopPropagation();
var element = e.target;
var el = document.getElementById("cap1");
el.label = "client: (" + e.clientX + "," + e.clientY + ")";
parent.arguments[0].SimpleTest.is(e.clientX, 3, "mouse event clientX on sub frame 1");
Expand All @@ -36,7 +35,7 @@ function mouseMove(e) {
frames[0].runTests();
}

window.addEventListener("mousemove", mouseMove, false);
window.addEventListener("mousemove", mouseMove);

</script>
</window>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function runTests()

function mouseMove(e) {
e.stopPropagation();
var element = e.target;
var el = document.getElementById("cap2");
el.label = "client: (" + e.clientX + "," + e.clientY + ")";
parent.parent.arguments[0].SimpleTest.is(e.clientX, 6, "mouse event clientX on sub frame 2");
Expand All @@ -32,7 +31,7 @@ function mouseMove(e) {
parent.parent.close();
}

window.addEventListener("mousemove",mouseMove, false);
window.addEventListener("mousemove", mouseMove);

</script>
</window>
2 changes: 1 addition & 1 deletion toolkit/content/tests/chrome/test_arrowpanel.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function* nextTest()
}

// Check that the transition occurs for an arrow panel with animate="true"
$("animatepanel").addEventListener("transitionend", transitionEnded, false);
$("animatepanel").addEventListener("transitionend", transitionEnded);
$("animatepanel").openPopup($("topleft"), "after_start", 0, 0, false, false, null, "start");
is($("animatepanel").state, "showing", "state is showing");
yield;
Expand Down
29 changes: 11 additions & 18 deletions toolkit/content/tests/chrome/test_autocomplete2.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,31 @@ nsAutoCompleteSimpleResult.prototype = {
defaultIndex: -1,
errorDescription: null,
matchCount: 0,
getValueAt: function() { return this._param; },
getCommentAt: function() { return null; },
getStyleAt: function() { return null; },
getImageAt: function() { return null; },
getFinalCompleteValueAt: function() { return this.getValueAt(); },
getLabelAt: function() { return null; },
removeValueAt: function() {}
getValueAt() { return this._param; },
getCommentAt() { return null; },
getStyleAt() { return null; },
getImageAtn() { return null; },
getFinalCompleteValueAt() { return this.getValueAt(); },
getLabelAt() { return null; },
removeValueAt() {}
};

// A basic autocomplete implementation that either returns one result or none
var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca");
var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple"
var autoCompleteSimple = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIFactory) ||
iid.equals(Ci.nsIAutoCompleteSearch))
return this;
QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]),

throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},

createInstance: function(outer, iid) {
createInstance(outer, iid) {
return this.QueryInterface(iid);
},

startSearch: function(aString, aParam, aResult, aListener) {
startSearch(aString, aParam, aResult, aListener) {
var result = new nsAutoCompleteSimpleResult(aString);
aListener.onSearchResult(this, result);
},

stopSearch: function() {}
stopSearch() {}
};

var componentManager = Components.manager
Expand Down
62 changes: 33 additions & 29 deletions toolkit/content/tests/chrome/test_autocomplete3.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,31 @@ nsAutoCompleteSimpleResult.prototype = {
defaultIndex: 0,
errorDescription: null,
matchCount: 0,
getValueAt: function() { return this._param; },
getCommentAt: function() { return null; },
getStyleAt: function() { return null; },
getImageAt: function() { return null; },
getFinalCompleteValueAt: function() { return this.getValueAt(); },
getLabelAt: function() { return null; },
removeValueAt: function() {}
getValueAt() { return this._param; },
getCommentAt() { return null; },
getStyleAt() { return null; },
getImageAt() { return null; },
getFinalCompleteValueAt() { return this.getValueAt(); },
getLabelAt() { return null; },
removeValueAt() {}
};

// A basic autocomplete implementation that either returns one result or none
var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca");
var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple"
var autoCompleteSimple = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIFactory) ||
iid.equals(Ci.nsIAutoCompleteSearch))
return this;
QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]),

throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},

createInstance: function(outer, iid) {
createInstance(outer, iid) {
return this.QueryInterface(iid);
},

startSearch: function(aString, aParam, aResult, aListener) {
startSearch(aString, aParam, aResult, aListener) {
var result = new nsAutoCompleteSimpleResult(aString);
aListener.onSearchResult(this, result);
},

stopSearch: function() {}
stopSearch() {}
};

var componentManager = Components.manager
Expand Down Expand Up @@ -142,7 +135,6 @@ function checkNext() {

function checkResult() {
var autocomplete = $("autocomplete");
var style = window.getComputedStyle(autocomplete);

is(autocomplete.value, tests[currentTest].result,
"Test " + currentTest + ": autocomplete.value should equal '" +
Expand All @@ -158,26 +150,38 @@ function checkResult() {

++currentTest;

if (currentTest < tests.length)
if (currentTest < tests.length) {
setTimeout(checkNext, 0);
else {
} else {
// TODO (bug 494809): Autocomplete-in-the-middle should take in count RTL
// and complete on KEY_ArrowRight or KEY_ArrowLeft based on that. It should also revert
// what user has typed to far if he moves in the opposite direction.
if (!autocomplete.value.includes(">>")) {
// Test result if user accepts autocomplete suggestion.
synthesizeKey("KEY_ArrowRight");
is(autocomplete.value, "Result",
"Test complete: autocomplete.value should equal 'Result'");
is(autocomplete.selectionStart, 6,
"Test complete: autocomplete selection should start at 6");
is(autocomplete.selectionEnd, 6,
"Test complete: autocomplete selection should end at 6");
is(
autocomplete.value,
"Result",
"Test complete: autocomplete.value should equal 'Result'"
);
is(
autocomplete.selectionStart,
6,
"Test complete: autocomplete selection should start at 6"
);
is(
autocomplete.selectionEnd,
6,
"Test complete: autocomplete selection should end at 6"
);
}

setTimeout(function() {
setTimeout(function () {
// Unregister the factory so that we don't get in the way of other tests
componentManager.unregisterFactory(autoCompleteSimpleID, autoCompleteSimple);
componentManager.unregisterFactory(
autoCompleteSimpleID,
autoCompleteSimple
);
SimpleTest.finish();
}, 0);
}
Expand Down
31 changes: 12 additions & 19 deletions toolkit/content/tests/chrome/test_autocomplete4.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,31 @@ nsAutoCompleteSimpleResult.prototype = {
defaultIndex: 0,
errorDescription: null,
matchCount: 0,
getValueAt: function() { return this._param; },
getCommentAt: function() { return null; },
getStyleAt: function() { return null; },
getImageAt: function() { return null; },
getFinalCompleteValueAt: function() { return this.getValueAt(); },
getLabelAt: function() { return null; },
removeValueAt: function() {}
getValueAt() { return this._param; },
getCommentAt() { return null; },
getStyleAt() { return null; },
getImageAt() { return null; },
getFinalCompleteValueAt() { return this.getValueAt(); },
getLabelAt() { return null; },
removeValueAt() {}
};

// A basic autocomplete implementation that either returns one result or none
var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca");
var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple"
var autoCompleteSimple = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIFactory) ||
iid.equals(Ci.nsIAutoCompleteSearch))
return this;
QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]),

throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},

createInstance: function(outer, iid) {
createInstance(outer, iid) {
return this.QueryInterface(iid);
},

startSearch: function(aString, aParam, aResult, aListener) {
startSearch(aString, aParam, aResult, aListener) {
var result = new nsAutoCompleteSimpleResult(aString);
aListener.onSearchResult(this, result);
},

stopSearch: function() {}
stopSearch() {}
};

var componentManager = Components.manager
Expand Down Expand Up @@ -221,7 +214,7 @@ function runCurrentTest() {

function searchComplete() {
var autocomplete = $("autocomplete");
autocomplete.setAttribute("forcecomplete", currentTest.forceComplete ? true : false);
autocomplete.setAttribute("forcecomplete", currentTest.forceComplete);

if (currentTest.completeFromMiddle) {
if (!currentTest.forceComplete) {
Expand Down
31 changes: 12 additions & 19 deletions toolkit/content/tests/chrome/test_autocomplete5.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,31 @@ nsAutoCompleteSimpleResult.prototype = {
defaultIndex: -1,
errorDescription: null,
matchCount: 0,
getValueAt: function() { return this._param; },
getCommentAt: function() { return null; },
getStyleAt: function() { return null; },
getImageAt: function() { return null; },
getFinalCompleteValueAt: function() { return this.getValueAt(); },
getLabelAt: function() { return null; },
removeValueAt: function() {}
getValueAt() { return this._param; },
getCommentAt() { return null; },
getStyleAt() { return null; },
getImageAt() { return null; },
getFinalCompleteValueAt() { return this.getValueAt(); },
getLabelAt() { return null; },
removeValueAt() {}
};

// A basic autocomplete implementation that either returns one result or none
var autoCompleteSimpleID = Components.ID("0a2afbdb-f30e-47d1-9cb1-0cd160240aca");
var autoCompleteSimpleName = "@mozilla.org/autocomplete/search;1?name=simple"
var autoCompleteSimple = {
QueryInterface: function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIFactory) ||
iid.equals(Ci.nsIAutoCompleteSearch))
return this;
QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]),

throw Components.Exception("", Cr.NS_ERROR_NO_INTERFACE);
},

createInstance: function(outer, iid) {
createInstance(outer, iid) {
return this.QueryInterface(iid);
},

startSearch: function(aString, aParam, aResult, aListener) {
startSearch(aString, aParam, aResult, aListener) {
var result = new nsAutoCompleteSimpleResult(aString);
aListener.onSearchResult(this, result);
},

stopSearch: function() {}
stopSearch() {}
};


Expand Down Expand Up @@ -129,7 +122,7 @@ function checkSearchCompleted() {
hasSearchBegun = false;
synthesizeKey("KEY_Escape");
} else {
throw "checkSearchCompleted should only be called twice.";
throw new Error("checkSearchCompleted should only be called twice.");
}
}

Expand Down
Loading

0 comments on commit 8b80449

Please sign in to comment.