mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1186396 - Remove remaining references to JQuery from Loop. r=andreio,r=Standard8
This commit is contained in:
parent
162b2b7543
commit
dfaf9979d9
@ -15,11 +15,9 @@
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"_": false,
|
||||
"$": false,
|
||||
"Backbone": false,
|
||||
"chai": false,
|
||||
"console": false,
|
||||
"jQuery": false,
|
||||
"loop": true,
|
||||
"MozActivity": false,
|
||||
"mozRTCSessionDescription": false,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -132,7 +132,6 @@
|
||||
</script>
|
||||
<script type="text/javascript" src="libs/l10n-gaia-02ca67948fe8.js"></script>
|
||||
<script type="text/javascript" src="shared/libs/react-0.12.2.js"></script>
|
||||
<script type="text/javascript" src="shared/libs/jquery-2.1.4.js"></script>
|
||||
<script type="text/javascript" src="shared/libs/lodash-3.9.3.js"></script>
|
||||
<script type="text/javascript" src="shared/libs/backbone-1.2.1.js"></script>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var loop = loop || {};
|
||||
loop.StandaloneClient = (function($) {
|
||||
loop.StandaloneClient = (function() {
|
||||
"use strict";
|
||||
|
||||
// The expected properties to be returned from the POST /calls request.
|
||||
@ -27,8 +27,8 @@ loop.StandaloneClient = (function($) {
|
||||
/**
|
||||
* Validates a data object to confirm it has the specified properties.
|
||||
*
|
||||
* @param {Object} The data object to verify
|
||||
* @param {Array} The list of properties to verify within the object
|
||||
* @param {Object} data The data object to verify
|
||||
* @param {Array} properties The list of properties to verify within the object
|
||||
* @return This returns either the specific property if only one
|
||||
* property is specified, or it returns all properties
|
||||
*/
|
||||
@ -55,13 +55,11 @@ loop.StandaloneClient = (function($) {
|
||||
* Generic handler for XHR failures.
|
||||
*
|
||||
* @param {Function} cb Callback(err)
|
||||
* @param jqXHR See jQuery docs
|
||||
* @param textStatus See jQuery docs
|
||||
* @param errorThrown See jQuery docs
|
||||
* @param xhrReq
|
||||
*/
|
||||
_failureHandler: function(cb, jqXHR, textStatus, errorThrown) {
|
||||
var jsonErr = jqXHR && jqXHR.responseJSON || {};
|
||||
var message = "HTTP " + jqXHR.status + " " + errorThrown;
|
||||
_failureHandler: function(cb, xhrReq) {
|
||||
var jsonErr = JSON.parse(xhrReq.responseText && xhrReq.responseText || "{}");
|
||||
var message = "HTTP " + xhrReq.status + " " + xhrReq.statusText;
|
||||
|
||||
// Logging the technical error to the console
|
||||
console.error("Server error", message, jsonErr);
|
||||
@ -88,10 +86,29 @@ loop.StandaloneClient = (function($) {
|
||||
throw new Error("Missing required callback function");
|
||||
}
|
||||
|
||||
$.get(this.settings.baseServerUrl + "/calls/" + loopToken)
|
||||
.done(function(callUrlInfo) {
|
||||
cb(null, callUrlInfo);
|
||||
}).fail(this._failureHandler.bind(this, cb));
|
||||
var url = this.settings.baseServerUrl + "/calls/" + loopToken;
|
||||
var xhrReq = new XMLHttpRequest();
|
||||
|
||||
xhrReq.open("GET", url, true);
|
||||
xhrReq.setRequestHeader("Content-type", "application/json");
|
||||
|
||||
xhrReq.onload = function() {
|
||||
var request = xhrReq;
|
||||
var responseJSON = JSON.parse(request.responseText || null);
|
||||
|
||||
if (request.readyState === 4 && request.status >= 200 && request.status < 300) {
|
||||
try {
|
||||
cb(null, responseJSON);
|
||||
} catch (err) {
|
||||
console.error("Error requesting call info", err.message);
|
||||
cb(err);
|
||||
}
|
||||
} else {
|
||||
this._failureHandler(cb, request);
|
||||
}
|
||||
}.bind(this, xhrReq);
|
||||
|
||||
xhrReq.send();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -108,26 +125,31 @@ loop.StandaloneClient = (function($) {
|
||||
throw new Error("missing required parameter loopToken");
|
||||
}
|
||||
|
||||
var req = $.ajax({
|
||||
url: this.settings.baseServerUrl + "/calls/" + loopToken,
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
data: JSON.stringify({callType: callType, channel: "standalone"})
|
||||
});
|
||||
var url = this.settings.baseServerUrl + "/calls/" + loopToken;
|
||||
var xhrReq = new XMLHttpRequest();
|
||||
|
||||
req.done(function(sessionData) {
|
||||
xhrReq.open("POST", url, true);
|
||||
xhrReq.setRequestHeader("Content-type", "application/json");
|
||||
|
||||
xhrReq.onload = function() {
|
||||
var request = xhrReq;
|
||||
var responseJSON = JSON.parse(request.responseText || null);
|
||||
|
||||
if (request.readyState === 4 && request.status >= 200 && request.status < 300) {
|
||||
try {
|
||||
cb(null, this._validate(sessionData, expectedCallsProperties));
|
||||
cb(null, this._validate(responseJSON, expectedCallsProperties));
|
||||
} catch (err) {
|
||||
console.error("Error requesting call info", err.message);
|
||||
cb(err);
|
||||
}
|
||||
}.bind(this));
|
||||
} else {
|
||||
this._failureHandler(cb, request);
|
||||
}
|
||||
}.bind(this, xhrReq);
|
||||
|
||||
req.fail(this._failureHandler.bind(this, cb));
|
||||
xhrReq.send(JSON.stringify({callType: callType, channel: "standalone"}));
|
||||
}
|
||||
};
|
||||
|
||||
return StandaloneClient;
|
||||
})(jQuery);
|
||||
})();
|
||||
|
@ -15,7 +15,6 @@ loop.StandaloneMozLoop = (function(mozL10n) {
|
||||
*/
|
||||
var ROOM_MAX_CLIENTS = 2;
|
||||
|
||||
|
||||
/**
|
||||
* Validates a data object to confirm it has the specified properties.
|
||||
*
|
||||
@ -36,16 +35,13 @@ loop.StandaloneMozLoop = (function(mozL10n) {
|
||||
* Generic handler for XHR failures.
|
||||
*
|
||||
* @param {Function} callback Callback(err)
|
||||
* @param jqXHR See jQuery docs
|
||||
* @param textStatus See jQuery docs
|
||||
* @param errorThrown See jQuery docs
|
||||
* @param xhrReq
|
||||
*/
|
||||
function failureHandler(callback, jqXHR, textStatus, errorThrown) {
|
||||
var jsonErr = jqXHR && jqXHR.responseJSON || {};
|
||||
var message = "HTTP " + jqXHR.status + " " + errorThrown;
|
||||
|
||||
function failureHandler(callback, xhrReq) {
|
||||
var jsonErr = JSON.parse(xhrReq.responseText && xhrReq.responseText || "{}");
|
||||
var message = "HTTP " + xhrReq.status + " " + xhrReq.statusText;
|
||||
// Create an error with server error `errno` code attached as a property
|
||||
var err = new Error(message + (jsonErr.error ? "; " + jsonErr.error : ""));
|
||||
var err = new Error(message);
|
||||
err.errno = jsonErr.errno;
|
||||
|
||||
callback(err);
|
||||
@ -76,30 +72,34 @@ loop.StandaloneMozLoop = (function(mozL10n) {
|
||||
* be the list of rooms, if it was fetched successfully.
|
||||
*/
|
||||
get: function(roomToken, callback) {
|
||||
var req = $.ajax({
|
||||
url: this._baseServerUrl + "/rooms/" + roomToken,
|
||||
method: "GET",
|
||||
contentType: "application/json",
|
||||
beforeSend: function(xhr) {
|
||||
if (this.sessionToken) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(this.sessionToken));
|
||||
}
|
||||
}.bind(this)
|
||||
});
|
||||
var url = this._baseServerUrl + "/rooms/" + roomToken;
|
||||
|
||||
req.done(function(responseData) {
|
||||
this._xhrReq = new XMLHttpRequest();
|
||||
this._xhrReq.open("GET", url, true);
|
||||
this._xhrReq.setRequestHeader("Content-type", "application/json");
|
||||
|
||||
if (this.sessionToken) {
|
||||
this._xhrReq.setRequestHeader("Authorization", "Basic " + btoa(this.sessionToken));
|
||||
}
|
||||
|
||||
this._xhrReq.onload = function() {
|
||||
var request = this._xhrReq;
|
||||
var responseJSON = JSON.parse(request.responseText || "{}");
|
||||
|
||||
if (request.readyState === 4 && request.status >= 200 && request.status < 300) {
|
||||
try {
|
||||
// We currently only require things we need rather than everything possible.
|
||||
callback(null, validate(responseData, {
|
||||
roomUrl: String
|
||||
}));
|
||||
callback(null, validate(responseJSON, { roomUrl: String }));
|
||||
} catch (err) {
|
||||
console.error("Error requesting call info", err.message);
|
||||
callback(err);
|
||||
}
|
||||
}.bind(this));
|
||||
} else {
|
||||
failureHandler(callback, request);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
req.fail(failureHandler.bind(this, callback));
|
||||
this._xhrReq.send();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -117,28 +117,33 @@ loop.StandaloneMozLoop = (function(mozL10n) {
|
||||
*/
|
||||
_postToRoom: function(roomToken, sessionToken, roomData, expectedProps,
|
||||
async, callback) {
|
||||
var req = $.ajax({
|
||||
url: this._baseServerUrl + "/rooms/" + roomToken,
|
||||
method: "POST",
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
data: JSON.stringify(roomData),
|
||||
beforeSend: function(xhr) {
|
||||
var url = this._baseServerUrl + "/rooms/" + roomToken;
|
||||
var xhrReq = new XMLHttpRequest();
|
||||
|
||||
xhrReq.open("POST", url, async);
|
||||
xhrReq.setRequestHeader("Content-type", "application/json");
|
||||
|
||||
if (sessionToken) {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa(sessionToken));
|
||||
xhrReq.setRequestHeader("Authorization", "Basic " + btoa(sessionToken));
|
||||
}
|
||||
},
|
||||
async: async,
|
||||
success: function(responseData) {
|
||||
|
||||
xhrReq.onload = function() {
|
||||
var request = xhrReq;
|
||||
var responseJSON = JSON.parse(request.responseText || null);
|
||||
|
||||
if (request.readyState === 4 && request.status >= 200 && request.status < 300) {
|
||||
try {
|
||||
callback(null, validate(responseData, expectedProps));
|
||||
callback(null, validate(responseJSON, expectedProps));
|
||||
} catch (err) {
|
||||
console.error("Error requesting call info", err.message);
|
||||
callback(err);
|
||||
}
|
||||
}.bind(this),
|
||||
error: failureHandler.bind(this, callback)
|
||||
});
|
||||
} else {
|
||||
failureHandler(callback, request);
|
||||
}
|
||||
}.bind(this, xhrReq);
|
||||
|
||||
xhrReq.send(JSON.stringify(roomData));
|
||||
},
|
||||
|
||||
/**
|
||||
@ -276,7 +281,6 @@ loop.StandaloneMozLoop = (function(mozL10n) {
|
||||
* Gets a preference from the local storage for standalone.
|
||||
*
|
||||
* @param {String} prefName The name of the pref
|
||||
* @param {String} value The value to set.
|
||||
*/
|
||||
getLoopPref: function(prefName) {
|
||||
return localStorage.getItem(prefName);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var loop = loop || {};
|
||||
loop.webapp = (function($, _, OT, mozL10n) {
|
||||
loop.webapp = (function(_, OT, mozL10n) {
|
||||
"use strict";
|
||||
|
||||
loop.config = loop.config || {};
|
||||
@ -1122,4 +1122,4 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
WebappRootView: WebappRootView,
|
||||
FxOSConversationModel: FxOSConversationModel
|
||||
};
|
||||
})(jQuery, _, window.OT, navigator.mozL10n);
|
||||
})(_, window.OT, navigator.mozL10n);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var loop = loop || {};
|
||||
loop.webapp = (function($, _, OT, mozL10n) {
|
||||
loop.webapp = (function(_, OT, mozL10n) {
|
||||
"use strict";
|
||||
|
||||
loop.config = loop.config || {};
|
||||
@ -1122,4 +1122,4 @@ loop.webapp = (function($, _, OT, mozL10n) {
|
||||
WebappRootView: WebappRootView,
|
||||
FxOSConversationModel: FxOSConversationModel
|
||||
};
|
||||
})(jQuery, _, window.OT, navigator.mozL10n);
|
||||
})(_, window.OT, navigator.mozL10n);
|
||||
|
@ -12,7 +12,6 @@ module.exports = function(config) {
|
||||
baseConfig.files = baseConfig.files.concat([
|
||||
"content/libs/l10n.js",
|
||||
"content/shared/libs/react-0.12.2.js",
|
||||
"content/shared/libs/jquery-2.1.4.js",
|
||||
"content/shared/libs/lodash-3.9.3.js",
|
||||
"content/shared/libs/backbone-1.2.1.js",
|
||||
"test/shared/vendor/*.js",
|
||||
|
@ -11,7 +11,6 @@ module.exports = function(config) {
|
||||
// List of files / patterns to load in the browser.
|
||||
baseConfig.files = baseConfig.files.concat([
|
||||
"standalone/content/libs/l10n-gaia-02ca67948fe8.js",
|
||||
"content/shared/libs/jquery-2.1.4.js",
|
||||
"content/shared/libs/lodash-3.9.3.js",
|
||||
"content/shared/libs/backbone-1.2.1.js",
|
||||
"content/shared/libs/react-0.12.2.js",
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
<!-- libs -->
|
||||
<script src="../../content/shared/libs/react-0.12.2.js"></script>
|
||||
<script src="../../content/shared/libs/jquery-2.1.4.js"></script>
|
||||
<script src="../../content/shared/libs/lodash-3.9.3.js"></script>
|
||||
<script src="../../content/shared/libs/backbone-1.2.1.js"></script>
|
||||
<script src="../../standalone/content/libs/l10n-gaia-02ca67948fe8.js"></script>
|
||||
|
@ -31,7 +31,6 @@
|
||||
<script src="fake-l10n.js"></script>
|
||||
<script src="../content/js/multiplexGum.js"></script>
|
||||
<script src="../content/shared/libs/react-0.12.2.js"></script>
|
||||
<script src="../content/shared/libs/jquery-2.1.4.js"></script>
|
||||
<script src="../content/shared/libs/lodash-3.9.3.js"></script>
|
||||
<script src="../content/shared/libs/backbone-1.2.1.js"></script>
|
||||
<script src="../content/shared/js/actions.js"></script>
|
||||
|
@ -1685,25 +1685,50 @@
|
||||
// this alongside our other unit tests but use the same harness.
|
||||
var expectedWarningsCount = 10;
|
||||
var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
|
||||
var resultsElement = document.querySelector("#results");
|
||||
var divFailuresNode = document.createElement("div");
|
||||
var pCompleteNode = document.createElement("p");
|
||||
var emNode = document.createElement("em");
|
||||
|
||||
if (uncaughtError || warningsMismatch) {
|
||||
$("#results").append("<div class='failures'><em>" +
|
||||
((uncaughtError && warningsMismatch) ? 2 : 1) + "</em></div>");
|
||||
var liTestFail = document.createElement("li");
|
||||
var h2Node = document.createElement("h2");
|
||||
var preErrorNode = document.createElement("pre");
|
||||
|
||||
divFailuresNode.className = "failures";
|
||||
emNode.innerHTML = ((uncaughtError && warningsMismatch) ? 2 : 1).toString();
|
||||
divFailuresNode.appendChild(emNode);
|
||||
resultsElement.appendChild(divFailuresNode);
|
||||
|
||||
if (warningsMismatch) {
|
||||
$("#results").append("<li class='test fail'>" +
|
||||
"<h2>Unexpected number of warnings detected in UI-Showcase</h2>" +
|
||||
"<pre class='error'>Got: " + caughtWarnings.length + "\n" +
|
||||
"Expected: " + expectedWarningsCount + "</pre></li>");
|
||||
liTestFail.className = "test";
|
||||
liTestFail.className = liTestFail.className + " fail";
|
||||
h2Node.innerHTML = "Unexpected number of warnings detected in UI-Showcase";
|
||||
preErrorNode.className = "error";
|
||||
preErrorNode.innerHTML = "Got: " + caughtWarnings.length + "\n" + "Expected: " + expectedWarningsCount;
|
||||
liTestFail.appendChild(h2Node);
|
||||
liTestFail.appendChild(preErrorNode);
|
||||
resultsElement.appendChild(liTestFail);
|
||||
}
|
||||
if (uncaughtError) {
|
||||
$("#results").append("<li class='test fail'>" +
|
||||
"<h2>Errors rendering UI-Showcase</h2>" +
|
||||
"<pre class='error'>" + uncaughtError + "\n" + uncaughtError.stack + "</pre>" +
|
||||
"</li>");
|
||||
liTestFail.className = "test";
|
||||
liTestFail.className = liTestFail.className + " fail";
|
||||
h2Node.innerHTML = "Errors rendering UI-Showcase";
|
||||
preErrorNode.className = "error";
|
||||
preErrorNode.innerHTML = uncaughtError + "\n" + uncaughtError.stack;
|
||||
liTestFail.appendChild(h2Node);
|
||||
liTestFail.appendChild(preErrorNode);
|
||||
resultsElement.appendChild(liTestFail);
|
||||
}
|
||||
} else {
|
||||
$("#results").append("<div class='failures'><em>0</em></div>");
|
||||
divFailuresNode.className = "failures";
|
||||
emNode.innerHTML = "0";
|
||||
divFailuresNode.appendChild(emNode);
|
||||
resultsElement.appendChild(divFailuresNode);
|
||||
}
|
||||
$("#results").append("<p id='complete'>Complete.</p>");
|
||||
pCompleteNode.id = "complete";
|
||||
pCompleteNode.innerHTML = "Completed";
|
||||
resultsElement.appendChild(pCompleteNode);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
@ -1685,25 +1685,50 @@
|
||||
// this alongside our other unit tests but use the same harness.
|
||||
var expectedWarningsCount = 10;
|
||||
var warningsMismatch = caughtWarnings.length !== expectedWarningsCount;
|
||||
var resultsElement = document.querySelector("#results");
|
||||
var divFailuresNode = document.createElement("div");
|
||||
var pCompleteNode = document.createElement("p");
|
||||
var emNode = document.createElement("em");
|
||||
|
||||
if (uncaughtError || warningsMismatch) {
|
||||
$("#results").append("<div class='failures'><em>" +
|
||||
((uncaughtError && warningsMismatch) ? 2 : 1) + "</em></div>");
|
||||
var liTestFail = document.createElement("li");
|
||||
var h2Node = document.createElement("h2");
|
||||
var preErrorNode = document.createElement("pre");
|
||||
|
||||
divFailuresNode.className = "failures";
|
||||
emNode.innerHTML = ((uncaughtError && warningsMismatch) ? 2 : 1).toString();
|
||||
divFailuresNode.appendChild(emNode);
|
||||
resultsElement.appendChild(divFailuresNode);
|
||||
|
||||
if (warningsMismatch) {
|
||||
$("#results").append("<li class='test fail'>" +
|
||||
"<h2>Unexpected number of warnings detected in UI-Showcase</h2>" +
|
||||
"<pre class='error'>Got: " + caughtWarnings.length + "\n" +
|
||||
"Expected: " + expectedWarningsCount + "</pre></li>");
|
||||
liTestFail.className = "test";
|
||||
liTestFail.className = liTestFail.className + " fail";
|
||||
h2Node.innerHTML = "Unexpected number of warnings detected in UI-Showcase";
|
||||
preErrorNode.className = "error";
|
||||
preErrorNode.innerHTML = "Got: " + caughtWarnings.length + "\n" + "Expected: " + expectedWarningsCount;
|
||||
liTestFail.appendChild(h2Node);
|
||||
liTestFail.appendChild(preErrorNode);
|
||||
resultsElement.appendChild(liTestFail);
|
||||
}
|
||||
if (uncaughtError) {
|
||||
$("#results").append("<li class='test fail'>" +
|
||||
"<h2>Errors rendering UI-Showcase</h2>" +
|
||||
"<pre class='error'>" + uncaughtError + "\n" + uncaughtError.stack + "</pre>" +
|
||||
"</li>");
|
||||
liTestFail.className = "test";
|
||||
liTestFail.className = liTestFail.className + " fail";
|
||||
h2Node.innerHTML = "Errors rendering UI-Showcase";
|
||||
preErrorNode.className = "error";
|
||||
preErrorNode.innerHTML = uncaughtError + "\n" + uncaughtError.stack;
|
||||
liTestFail.appendChild(h2Node);
|
||||
liTestFail.appendChild(preErrorNode);
|
||||
resultsElement.appendChild(liTestFail);
|
||||
}
|
||||
} else {
|
||||
$("#results").append("<div class='failures'><em>0</em></div>");
|
||||
divFailuresNode.className = "failures";
|
||||
emNode.innerHTML = "0";
|
||||
divFailuresNode.appendChild(emNode);
|
||||
resultsElement.appendChild(divFailuresNode);
|
||||
}
|
||||
$("#results").append("<p id='complete'>Complete.</p>");
|
||||
pCompleteNode.id = "complete";
|
||||
pCompleteNode.innerHTML = "Completed";
|
||||
resultsElement.appendChild(pCompleteNode);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user