Issue N/A - Undeprecate viewSource.xul's original API

This commit is contained in:
NTD 2018-02-02 07:52:31 -05:00 • committed by Roy Tam
commit 9aa9ebf294
3 changed files with 21 additions and 68 deletions

View file

@ -43,7 +43,7 @@ var ViewSourceContent = {
*/ */
messages: [ messages: [
"ViewSource:LoadSource", "ViewSource:LoadSource",
"ViewSource:LoadSourceDeprecated", "ViewSource:LoadSourceOriginal",
"ViewSource:LoadSourceWithSelection", "ViewSource:LoadSourceWithSelection",
"ViewSource:GoToLine", "ViewSource:GoToLine",
"ViewSource:ToggleWrapping", "ViewSource:ToggleWrapping",
@ -131,8 +131,8 @@ var ViewSourceContent = {
this.viewSource(data.URL, data.outerWindowID, data.lineNumber, this.viewSource(data.URL, data.outerWindowID, data.lineNumber,
data.shouldWrap); data.shouldWrap);
break; break;
case "ViewSource:LoadSourceDeprecated": case "ViewSource:LoadSourceOriginal":
this.viewSourceDeprecated(data.URL, objects.pageDescriptor, data.lineNumber, this.viewSourceOriginal(data.URL, objects.pageDescriptor, data.lineNumber,
data.forcedCharSet); data.forcedCharSet);
break; break;
case "ViewSource:LoadSourceWithSelection": case "ViewSource:LoadSourceWithSelection":
@ -245,7 +245,7 @@ var ViewSourceContent = {
}, },
/** /**
* Called when the parent is using the deprecated API for viewSource.xul. * Called when the parent is using the original API for viewSource.xul.
* This function will throw if it's called on a remote browser. * This function will throw if it's called on a remote browser.
* *
* @param URL (required) * @param URL (required)
@ -260,11 +260,11 @@ var ViewSourceContent = {
* @param forcedCharSet (optional) * @param forcedCharSet (optional)
* The document character set to use instead of the default one. * The document character set to use instead of the default one.
*/ */
viewSourceDeprecated(URL, pageDescriptor, lineNumber, forcedCharSet) { viewSourceOriginal(URL, pageDescriptor, lineNumber, forcedCharSet) {
// This should not be called if this frame script is running // This should not be called if this frame script is running
// in a content process! // in a content process!
if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_DEFAULT) { if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_DEFAULT) {
throw new Error("ViewSource deprecated API should not be used with " + throw new Error("ViewSource original API should not be used with " +
"remote browsers."); "remote browsers.");
} }
@ -272,7 +272,7 @@ var ViewSourceContent = {
}, },
/** /**
* Common utility function used by both the current and deprecated APIs * Common utility function used by both the current and orginal APIs
* for loading source. * for loading source.
* *
* @param URL (required) * @param URL (required)

View file

@ -13,8 +13,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm"); "resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu", XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
"resource://gre/modules/CharsetMenu.jsm"); "resource://gre/modules/CharsetMenu.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");
[ [
["gBrowser", "content"], ["gBrowser", "content"],
@ -260,7 +258,7 @@ ViewSourceChrome.prototype = {
* lineNumber (optional): * lineNumber (optional):
* The line number to focus on once the source is loaded. * The line number to focus on once the source is loaded.
* *
* The deprecated API has the opener pass in a number of arguments: * The original API has the opener pass in a number of arguments:
* *
* arg[0] - URL string. * arg[0] - URL string.
* arg[1] - Charset value string in the form 'charset=xxx'. * arg[1] - Charset value string in the form 'charset=xxx'.
@ -305,8 +303,8 @@ ViewSourceChrome.prototype = {
} }
if (typeof window.arguments[0] == "string") { if (typeof window.arguments[0] == "string") {
// We're using the deprecated API // We're using the original API
return this._loadViewSourceDeprecated(window.arguments); return this._loadViewSourceOriginal(window.arguments);
} }
// We're using the modern API, which allows us to view the // We're using the modern API, which allows us to view the
@ -322,13 +320,10 @@ ViewSourceChrome.prototype = {
}, },
/** /**
* This is the deprecated API for viewSource.xul, for old-timer consumers. * This is the original API for viewSource.xul, for old-timer consumers.
* This API might eventually go away. * This API might eventually go away.
*/ */
_loadViewSourceDeprecated(aArguments) { _loadViewSourceOriginal(aArguments) {
Deprecated.warning("The arguments you're passing to viewSource.xul " +
"are using an out-of-date API.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
// Parse the 'arguments' supplied with the dialog. // Parse the 'arguments' supplied with the dialog.
// arg[0] - URL string. // arg[0] - URL string.
// arg[1] - Charset value in the form 'charset=xxx'. // arg[1] - Charset value in the form 'charset=xxx'.
@ -344,7 +339,7 @@ ViewSourceChrome.prototype = {
} }
if (this.browser.isRemoteBrowser) { if (this.browser.isRemoteBrowser) {
throw new Error("Deprecated view source API should not use a remote browser."); throw new Error("Original view source API should not use a remote browser.");
} }
let forcedCharSet; let forcedCharSet;
@ -352,7 +347,7 @@ ViewSourceChrome.prototype = {
forcedCharSet = aArguments[1].split("=")[1]; forcedCharSet = aArguments[1].split("=")[1];
} }
this.sendAsyncMessage("ViewSource:LoadSourceDeprecated", { this.sendAsyncMessage("ViewSource:LoadSourceOriginal", {
URL: aArguments[0], URL: aArguments[0],
lineNumber: aArguments[3], lineNumber: aArguments[3],
forcedCharSet, forcedCharSet,
@ -787,49 +782,31 @@ function ViewSourceSavePage()
gPageLoader); gPageLoader);
} }
// Below are old deprecated functions and variables left behind for // Below are original functions and variables left behind for
// compatibility reasons. These will be removed soon via bug 1159293. // compatibility reasons. These will be removed soon via bug 1159293.
this.__defineGetter__("gLastLineFound", function () { this.__defineGetter__("gLastLineFound", function () {
Deprecated.warning("gLastLineFound is deprecated - please use " +
"viewSourceChrome.lastLineFound instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
return viewSourceChrome.lastLineFound; return viewSourceChrome.lastLineFound;
}); });
function onLoadViewSource() { function onLoadViewSource() {
Deprecated.warning("onLoadViewSource() is deprecated - please use " +
"viewSourceChrome.onXULLoaded() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.onXULLoaded(); viewSourceChrome.onXULLoaded();
} }
function isHistoryEnabled() { function isHistoryEnabled() {
Deprecated.warning("isHistoryEnabled() is deprecated - please use " +
"viewSourceChrome.historyEnabled instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
return viewSourceChrome.historyEnabled; return viewSourceChrome.historyEnabled;
} }
function ViewSourceClose() { function ViewSourceClose() {
Deprecated.warning("ViewSourceClose() is deprecated - please use " +
"viewSourceChrome.close() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.close(); viewSourceChrome.close();
} }
function ViewSourceReload() { function ViewSourceReload() {
Deprecated.warning("ViewSourceReload() is deprecated - please use " +
"viewSourceChrome.reload() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.reload(); viewSourceChrome.reload();
} }
function getWebNavigation() function getWebNavigation()
{ {
Deprecated.warning("getWebNavigation() is deprecated - please use " +
"viewSourceChrome.webNav instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
// The original implementation returned null if anything threw during // The original implementation returned null if anything threw during
// the getting of the webNavigation. // the getting of the webNavigation.
try { try {
@ -840,45 +817,27 @@ function getWebNavigation()
} }
function viewSource(url) { function viewSource(url) {
Deprecated.warning("viewSource() is deprecated - please use " +
"viewSourceChrome.loadURL() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.loadURL(url); viewSourceChrome.loadURL(url);
} }
function ViewSourceGoToLine() function ViewSourceGoToLine()
{ {
Deprecated.warning("ViewSourceGoToLine() is deprecated - please use " +
"viewSourceChrome.promptAndGoToLine() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.promptAndGoToLine(); viewSourceChrome.promptAndGoToLine();
} }
function goToLine(line) function goToLine(line)
{ {
Deprecated.warning("goToLine() is deprecated - please use " +
"viewSourceChrome.goToLine() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.goToLine(line); viewSourceChrome.goToLine(line);
} }
function BrowserForward(aEvent) { function BrowserForward(aEvent) {
Deprecated.warning("BrowserForward() is deprecated - please use " +
"viewSourceChrome.goForward() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.goForward(); viewSourceChrome.goForward();
} }
function BrowserBack(aEvent) { function BrowserBack(aEvent) {
Deprecated.warning("BrowserBack() is deprecated - please use " +
"viewSourceChrome.goBack() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.goBack(); viewSourceChrome.goBack();
} }
function UpdateBackForwardCommands() { function UpdateBackForwardCommands() {
Deprecated.warning("UpdateBackForwardCommands() is deprecated - please use " +
"viewSourceChrome.updateCommands() instead.",
"https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
viewSourceChrome.updateCommands(); viewSourceChrome.updateCommands();
} }

View file

@ -15,8 +15,6 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ViewSourceBrowser", XPCOMUtils.defineLazyModuleGetter(this, "ViewSourceBrowser",
"resource://gre/modules/ViewSourceBrowser.jsm"); "resource://gre/modules/ViewSourceBrowser.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm"); "resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services", XPCOMUtils.defineLazyModuleGetter(this, "Services",
@ -51,12 +49,12 @@ var gViewSourceUtils = {
* lineNumber (optional): * lineNumber (optional):
* The line number to focus on once the source is loaded. * The line number to focus on once the source is loaded.
* *
* @param aPageDescriptor (deprecated, optional) * @param aPageDescriptor (optional)
* Accepted for compatibility reasons, but is otherwise ignored. * Accepted for compatibility reasons, but is otherwise ignored.
* @param aDocument (deprecated, optional) * @param aDocument (optional)
* The content document we would like to view the source of. This * The content document we would like to view the source of. This
* function will throw if aDocument is a CPOW. * function will throw if aDocument is a CPOW.
* @param aLineNumber (deprecated, optional) * @param aLineNumber (optional)
* The line number to focus on once the source is loaded. * The line number to focus on once the source is loaded.
*/ */
viewSource: function(aArgsOrURL, aPageDescriptor, aDocument, aLineNumber) viewSource: function(aArgsOrURL, aPageDescriptor, aDocument, aLineNumber)
@ -213,12 +211,12 @@ var gViewSourceUtils = {
* lineNumber (optional): * lineNumber (optional):
* The line number to focus on once the source is loaded. * The line number to focus on once the source is loaded.
* *
* @param aPageDescriptor (deprecated, optional) * @param aPageDescriptor (optional)
* Accepted for compatibility reasons, but is otherwise ignored. * Accepted for compatibility reasons, but is otherwise ignored.
* @param aDocument (deprecated, optional) * @param aDocument (optional)
* The content document we would like to view the source of. This * The content document we would like to view the source of. This
* function will throw if aDocument is a CPOW. * function will throw if aDocument is a CPOW.
* @param aLineNumber (deprecated, optional) * @param aLineNumber (optional)
* The line number to focus on once the source is loaded. * The line number to focus on once the source is loaded.
* @param aCallBack * @param aCallBack
* A function accepting two arguments: * A function accepting two arguments:
@ -231,10 +229,6 @@ var gViewSourceUtils = {
aLineNumber, aCallBack) { aLineNumber, aCallBack) {
let data; let data;
if (typeof aArgsOrURL == "string") { if (typeof aArgsOrURL == "string") {
Deprecated.warning("The arguments you're passing to " +
"openInExternalEditor are using an out-of-date API.",
"https://developer.mozilla.org/en-US/Add-ons/" +
"Code_snippets/View_Source_for_XUL_Applications");
if (Components.utils.isCrossProcessWrapper(aDocument)) { if (Components.utils.isCrossProcessWrapper(aDocument)) {
throw new Error("View Source cannot accept a CPOW as a document."); throw new Error("View Source cannot accept a CPOW as a document.");
} }