From b013f58f8017cceac17c0e925bb6c3ccc8c5d1ed Mon Sep 17 00:00:00 2001 From: Geoff Lankow Date: Fri, 22 Jul 2016 12:12:11 +1200 Subject: [PATCH] Bug 1284166 - s do not properly handle non-ASCII characters. r=kmag --- mobile/android/chrome/content/aboutAddons.js | 2 + mobile/android/themes/core/aboutAddons.css | 4 -- .../mozapps/extensions/content/extensions.js | 2 + .../mozapps/extensions/content/setting.xml | 46 +++++------------- .../test/browser/browser_inlinesettings.js | 47 ++++++++++--------- .../browser/browser_inlinesettings_info.js | 3 +- .../extensions/test/browser/more_options.xul | 2 +- 7 files changed, 43 insertions(+), 63 deletions(-) diff --git a/mobile/android/chrome/content/aboutAddons.js b/mobile/android/chrome/content/aboutAddons.js index 0c190d537dee..fc0a6cc69703 100644 --- a/mobile/android/chrome/content/aboutAddons.js +++ b/mobile/android/chrome/content/aboutAddons.js @@ -25,6 +25,8 @@ XPCOMUtils.defineLazyGetter(window, "gChromeWin", function() { .getInterface(Ci.nsIDOMWindow) .QueryInterface(Ci.nsIDOMChromeWindow); }); +XPCOMUtils.defineLazyModuleGetter(window, "Preferences", + "resource://gre/modules/Preferences.jsm"); var ContextMenus = { target: null, diff --git a/mobile/android/themes/core/aboutAddons.css b/mobile/android/themes/core/aboutAddons.css index c3713ab0ee1f..c44b330ea342 100644 --- a/mobile/android/themes/core/aboutAddons.css +++ b/mobile/android/themes/core/aboutAddons.css @@ -259,10 +259,6 @@ select { /* XBL bindings */ -settings { - -moz-binding: url("chrome://mozapps/content/extensions/setting.xml#settings"); -} - setting { display: none; } diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index d7ceafbec2ee..d983eaa596db 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -26,6 +26,8 @@ const SIGNING_REQUIRED = CONSTANTS.REQUIRE_SIGNING ? XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Preferences", + "resource://gre/modules/Preferences.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Experiments", "resource:///modules/experiments/Experiments.jsm"); diff --git a/toolkit/mozapps/extensions/content/setting.xml b/toolkit/mozapps/extensions/content/setting.xml index 6101934e8d95..594ee666a0cc 100644 --- a/toolkit/mozapps/extensions/content/setting.xml +++ b/toolkit/mozapps/extensions/content/setting.xml @@ -15,13 +15,6 @@ xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - - - - - - @@ -308,10 +300,7 @@ @@ -397,7 +386,7 @@ @@ -405,7 +394,7 @@ @@ -460,20 +449,7 @@ diff --git a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js index 5e4d42432d6b..a4a5d85df57f 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js +++ b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings.js @@ -3,6 +3,7 @@ */ // Tests various aspects of the details view +Components.utils.import("resource://gre/modules/Preferences.jsm"); var gManagerWindow; var gCategoryUtilities; @@ -249,10 +250,11 @@ add_test(function() { EventUtils.synthesizeKey("a", {}, gManagerWindow); EventUtils.synthesizeKey("r", {}, gManagerWindow); is(input.value, "bar", "Text box should have updated value"); + input.value += "\u03DE"; // Cheat to add this non-ASCII character without typing it. EventUtils.synthesizeKey("/", {}, gManagerWindow); - is(input.value, "bar/", "Text box should have updated value"); + is(input.value, "bar\u03DE/", "Text box should have updated value"); is(gManagerWindow.document.getBindingParent(gManagerWindow.document.activeElement), input, "Search box should not have focus"); - is(Services.prefs.getCharPref("extensions.inlinesettings1.string"), "bar/", "String pref should have been updated"); + is(Preferences.get("extensions.inlinesettings1.string", "wrong"), "bar\u03DE/", "String pref should have been updated"); ok(!settings[4].hasAttribute("first-row"), "Not the first row"); input = settings[4].firstElementChild; @@ -282,24 +284,25 @@ add_test(function() { is(input.value, "", "Label value should be empty"); is(input.tooltipText, "", "Label tooltip should be empty"); - var profD = Services.dirsvc.get("ProfD", Ci.nsIFile); + var testFile = Services.dirsvc.get("ProfD", Ci.nsIFile); + testFile.append("\u2622"); var curProcD = Services.dirsvc.get("CurProcD", Ci.nsIFile); - MockFilePicker.returnFiles = [profD]; + MockFilePicker.returnFiles = [testFile]; MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK; EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); is(MockFilePicker.mode, Ci.nsIFilePicker.modeOpen, "File picker mode should be open file"); - is(input.value, profD.path, "Label value should match file chosen"); - is(input.tooltipText, profD.path, "Label tooltip should match file chosen"); - is(Services.prefs.getCharPref("extensions.inlinesettings1.file"), profD.path, "File pref should match file chosen"); + is(input.value, testFile.path, "Label value should match file chosen"); + is(input.tooltipText, testFile.path, "Label tooltip should match file chosen"); + is(Preferences.get("extensions.inlinesettings1.file", "wrong"), testFile.path, "File pref should match file chosen"); MockFilePicker.returnFiles = [curProcD]; MockFilePicker.returnValue = Ci.nsIFilePicker.returnCancel; EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); is(MockFilePicker.mode, Ci.nsIFilePicker.modeOpen, "File picker mode should be open file"); - is(input.value, profD.path, "Label value should not have changed"); - is(input.tooltipText, profD.path, "Label tooltip should not have changed"); - is(Services.prefs.getCharPref("extensions.inlinesettings1.file"), profD.path, "File pref should not have changed"); + is(input.value, testFile.path, "Label value should not have changed"); + is(input.tooltipText, testFile.path, "Label tooltip should not have changed"); + is(Preferences.get("extensions.inlinesettings1.file", "wrong"), testFile.path, "File pref should not have changed"); ok(!settings[7].hasAttribute("first-row"), "Not the first row"); button = gManagerWindow.document.getAnonymousElementByAttribute(settings[7], "anonid", "button"); @@ -307,21 +310,21 @@ add_test(function() { is(input.value, "", "Label value should be empty"); is(input.tooltipText, "", "Label tooltip should be empty"); - MockFilePicker.returnFiles = [profD]; + MockFilePicker.returnFiles = [testFile]; MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK; EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); is(MockFilePicker.mode, Ci.nsIFilePicker.modeGetFolder, "File picker mode should be directory"); - is(input.value, profD.path, "Label value should match file chosen"); - is(input.tooltipText, profD.path, "Label tooltip should match file chosen"); - is(Services.prefs.getCharPref("extensions.inlinesettings1.directory"), profD.path, "Directory pref should match file chosen"); + is(input.value, testFile.path, "Label value should match file chosen"); + is(input.tooltipText, testFile.path, "Label tooltip should match file chosen"); + is(Preferences.get("extensions.inlinesettings1.directory", "wrong"), testFile.path, "Directory pref should match file chosen"); MockFilePicker.returnFiles = [curProcD]; MockFilePicker.returnValue = Ci.nsIFilePicker.returnCancel; EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); is(MockFilePicker.mode, Ci.nsIFilePicker.modeGetFolder, "File picker mode should be directory"); - is(input.value, profD.path, "Label value should not have changed"); - is(input.tooltipText, profD.path, "Label tooltip should not have changed"); - is(Services.prefs.getCharPref("extensions.inlinesettings1.directory"), profD.path, "Directory pref should not have changed"); + is(input.value, testFile.path, "Label value should not have changed"); + is(input.tooltipText, testFile.path, "Label tooltip should not have changed"); + is(Preferences.get("extensions.inlinesettings1.directory", "wrong"), testFile.path, "Directory pref should not have changed"); var unsizedInput = gManagerWindow.document.getAnonymousElementByAttribute(settings[2], "anonid", "input"); var sizedInput = gManagerWindow.document.getAnonymousElementByAttribute(settings[8], "anonid", "input"); @@ -380,9 +383,9 @@ add_test(function() { is(radios[1].selected, true, "Correct radio button should be selected"); isnot(radios[2].selected, true, "Correct radio button should be selected"); EventUtils.synthesizeMouseAtCenter(radios[0], { clickCount: 1 }, gManagerWindow); - is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "india", "Radio pref should have been updated"); + is(Preferences.get("extensions.inlinesettings3.radioString", "wrong"), "india", "Radio pref should have been updated"); EventUtils.synthesizeMouseAtCenter(radios[2], { clickCount: 1 }, gManagerWindow); - is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "kilo", "Radio pref should have been updated"); + is(Preferences.get("extensions.inlinesettings3.radioString", "wrong"), "kilo \u338F", "Radio pref should have been updated"); ok(!settings[3].hasAttribute("first-row"), "Not the first row"); Services.prefs.setIntPref("extensions.inlinesettings3.menulist", 8); @@ -588,7 +591,7 @@ add_test(function() { Services.prefs.setBoolPref("extensions.inlinesettings1.bool", false); Services.prefs.setIntPref("extensions.inlinesettings1.boolint", 1); Services.prefs.setIntPref("extensions.inlinesettings1.integer", 12); - Services.prefs.setCharPref("extensions.inlinesettings1.string", "bar/"); + Preferences.set("extensions.inlinesettings1.string", "bar\u03DE/"); Services.prefs.setCharPref("extensions.inlinesettings1.color", "#FF9900"); Services.prefs.setCharPref("extensions.inlinesettings1.file", profD.path); Services.prefs.setCharPref("extensions.inlinesettings1.directory", profD.path); @@ -615,7 +618,7 @@ add_test(function() { is(input.value, "12", "Number box should have initial value"); input = gManagerWindow.document.getAnonymousElementByAttribute(settings[3], "anonid", "input"); - is(input.value, "bar/", "Text box should have initial value"); + is(input.value, "bar\u03DE/", "Text box should have initial value"); input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input"); is(input.color, "#FF9900", "Color picker should have initial value"); @@ -640,7 +643,7 @@ add_test(function() { // change the tests above. Services.prefs.setBoolPref("extensions.inlinesettings3.radioBool", false); Services.prefs.setIntPref("extensions.inlinesettings3.radioInt", 6); - Services.prefs.setCharPref("extensions.inlinesettings3.radioString", "kilo"); + Preferences.set("extensions.inlinesettings3.radioString", "kilo \u338F"); Services.prefs.setIntPref("extensions.inlinesettings3.menulist", 9); var addon = get_addon_element(gManagerWindow, "inlinesettings3@tests.mozilla.org"); diff --git a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_info.js b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_info.js index 384c126bee15..0251039d23c4 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_info.js +++ b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_info.js @@ -3,6 +3,7 @@ */ // Tests various aspects of the details view +Components.utils.import("resource://gre/modules/Preferences.jsm"); var gManagerWindow; var gCategoryUtilities; @@ -376,7 +377,7 @@ add_test(function() { EventUtils.synthesizeMouseAtCenter(radios[0], { clickCount: 1 }, gManagerWindow); is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "india", "Radio pref should have been updated"); EventUtils.synthesizeMouseAtCenter(radios[2], { clickCount: 1 }, gManagerWindow); - is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "kilo", "Radio pref should have been updated"); + is(Preferences.get("extensions.inlinesettings3.radioString", "wrong"), "kilo \u338F", "Radio pref should have been updated"); ok(!settings[3].hasAttribute("first-row"), "Not the first row"); Services.prefs.setIntPref("extensions.inlinesettings3.menulist", 8); diff --git a/toolkit/mozapps/extensions/test/browser/more_options.xul b/toolkit/mozapps/extensions/test/browser/more_options.xul index 4c8474a7982c..28dbb0a2e0c3 100644 --- a/toolkit/mozapps/extensions/test/browser/more_options.xul +++ b/toolkit/mozapps/extensions/test/browser/more_options.xul @@ -17,7 +17,7 @@ - +