Merge m-c to mozilla-inbound

This commit is contained in:
Carsten "Tomcat" Book 2013-09-18 12:42:44 +02:00
commit 4b4afba78d
15 changed files with 205 additions and 1611 deletions

View File

@ -1,4 +1,4 @@
{
"revision": "94340fb19f685f3cd6e5fa990281557ba810a10e",
"revision": "d9e4d98a9fba0dec670fe2446bea31e464add944",
"repo_path": "/integration/gaia-central"
}

View File

@ -2596,6 +2596,13 @@ let SessionStoreInternal = {
tabbrowser.unpinTab(tabbrowser.tabs[t]);
}
// We need to keep track of the initially open tabs so that they
// can be moved to the end of the restored tabs.
let initialTabs = [];
if (!overwriteTabs && firstWindow) {
initialTabs = Array.slice(tabbrowser.tabs);
}
// make sure that the selected tab won't be closed in order to
// prevent unnecessary flickering
if (overwriteTabs && tabbrowser.selectedTab._tPos >= newTabCount)
@ -2607,10 +2614,6 @@ let SessionStoreInternal = {
tabs.push(t < openTabCount ?
tabbrowser.tabs[t] :
tabbrowser.addTab("about:blank", {skipAnimation: true}));
// when resuming at startup: add additionally requested pages to the end
if (!overwriteTabs && firstWindow) {
tabbrowser.moveTabTo(tabs[t], t);
}
if (winData.tabs[t].pinned)
tabbrowser.pinTab(tabs[t]);
@ -2624,6 +2627,14 @@ let SessionStoreInternal = {
}
}
if (!overwriteTabs && firstWindow) {
// Move the originally open tabs to the end
let endPosition = tabbrowser.tabs.length - 1;
for (let i = 0; i < initialTabs.length; i++) {
tabbrowser.moveTabTo(initialTabs[i], endPosition);
}
}
// if all tabs to be restored are hidden, make the first one visible
if (!numVisibleTabs && winData.tabs.length) {
winData.tabs[0].hidden = false;

View File

@ -327,11 +327,15 @@ XPCOMUtils.defineLazyModuleGetter(this, "AppCacheUtils",
let name = representAddon(addon);
let message = "";
if (addon.userDisabled) {
message = gcli.lookupFormat("addonAlreadyDisabled", [name]);
} else {
// If the addon is not disabled or is set to "click to play" then
// disable it. Otherwise display the message "Add-on is already
// disabled."
if (!addon.userDisabled ||
addon.userDisabled === AddonManager.STATE_ASK_TO_ACTIVATE) {
addon.userDisabled = true;
message = gcli.lookupFormat("addonDisabled", [name]);
} else {
message = gcli.lookupFormat("addonAlreadyDisabled", [name]);
}
this.resolve(message);
}

View File

@ -80,7 +80,7 @@ function test() {
function testWhenBreakpointEnabledAndSecondSourceShown() {
return Task.spawn(function() {
yield ensureSourceIs(aPanel, "-02.js");
yield ensureSourceIs(aPanel, "-02.js", true);
yield verifyView({ disabled: false, visible: false });
executeSoon(() => aDebuggee.firstCall());
@ -95,7 +95,7 @@ function test() {
function testWhenBreakpointDisabledAndSecondSourceShown() {
return Task.spawn(function() {
yield ensureSourceIs(aPanel, "-02.js");
yield ensureSourceIs(aPanel, "-02.js", true);
yield verifyView({ disabled: true, visible: false });
executeSoon(() => aDebuggee.firstCall());

File diff suppressed because it is too large Load Diff

View File

@ -341,14 +341,13 @@ function waitForEvent(aSubject, aEventName, aTimeoutMs, aTarget) {
eventDeferred.resolve(aEvent);
}
function cleanup() {
function cleanup(aEventOrError) {
// unhook listener in case of success or failure
aSubject.removeEventListener(aEventName, listener);
return aEventOrError;
}
eventDeferred.promise.then(cleanup, cleanup);
aSubject.addEventListener(aEventName, listener, false);
return eventDeferred.promise;
return eventDeferred.promise.then(cleanup, cleanup);
}
/**
@ -425,7 +424,7 @@ function waitForCondition(aCondition, aTimeoutMs, aIntervalMs) {
}
/**
* same as waitForCondition but with better test output.
* same as waitForCondition but with better test output.
*
* @param aCondition the callback that must return a truthy value
* @param aTestMsg test condition message printed when the test succeeds or

View File

@ -11,8 +11,7 @@ import os
def get_build_entries(root_path):
""" Iterates through the root_path, creating a list for each file and
directory. Excludes any path starting with extensions or distribution
and paths ending with channel-prefs.js.
directory. Excludes any file paths ending with channel-prefs.js.
"""
rel_file_path_set = set()
rel_dir_path_set = set()
@ -21,18 +20,14 @@ def get_build_entries(root_path):
parent_dir_rel_path = root[len(root_path)+1:]
rel_path_file = os.path.join(parent_dir_rel_path, file_name)
rel_path_file = rel_path_file.replace("\\", "/")
if not (rel_path_file.startswith("distribution/") or
rel_path_file.startswith("extensions/") or
rel_path_file.endswith("channel-prefs.js")):
if not (rel_path_file.endswith("channel-prefs.js")):
rel_file_path_set.add(rel_path_file)
for dir_name in dirs:
parent_dir_rel_path = root[len(root_path)+1:]
rel_path_dir = os.path.join(parent_dir_rel_path, dir_name)
rel_path_dir = rel_path_dir.replace("\\", "/")+"/"
if not (rel_path_dir.startswith("distribution/") or
rel_path_dir.startswith("extensions/")):
rel_dir_path_set.add(rel_path_dir)
rel_dir_path_set.add(rel_path_dir)
rel_file_path_list = list(rel_file_path_set)
rel_file_path_list.sort(reverse=True)

View File

@ -20,6 +20,7 @@ import org.mozilla.gecko.util.HardwareUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.UiAsyncTask;
import org.mozilla.gecko.util.GeckoEventListener;
import org.mozilla.gecko.util.StringUtils;
import org.json.JSONObject;
@ -1092,8 +1093,7 @@ public class BrowserToolbar extends GeckoRelativeLayout
return;
}
url = StringUtils.stripScheme(url);
CharSequence title = StringUtils.stripCommonSubdomains(url);
CharSequence title = StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url));
String baseDomain = tab.getBaseDomain();
if (!TextUtils.isEmpty(baseDomain)) {

View File

@ -13,9 +13,18 @@ import org.json.JSONArray;
import org.json.JSONObject;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Build;
import android.text.format.DateFormat;
import android.text.Html;
import android.text.InputType;
import android.text.TextUtils;
import android.util.Log;
import android.view.inputmethod.InputMethodManager;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.DatePicker;
@ -24,14 +33,6 @@ import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TimePicker;
import android.text.InputType;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Log;
import android.text.Html;
import android.widget.ArrayAdapter;
import android.view.ViewGroup.LayoutParams;
import android.view.inputmethod.InputMethodManager;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@ -91,6 +92,21 @@ class PromptInput {
}
}
public static class NumberInput extends EditInput {
public static final String INPUT_TYPE = "number";
public NumberInput(JSONObject obj) {
super(obj);
}
public View getView(final Context context) throws UnsupportedOperationException {
EditText input = (EditText) super.getView(context);
input.setRawInputType(Configuration.KEYBOARD_12KEY);
input.setInputType(InputType.TYPE_CLASS_NUMBER |
InputType.TYPE_NUMBER_FLAG_SIGNED);
return input;
}
}
public static class PasswordInput extends EditInput {
public static final String INPUT_TYPE = "password";
public PasswordInput(JSONObject obj) {
@ -324,6 +340,8 @@ class PromptInput {
String type = obj.optString("type");
if (EditInput.INPUT_TYPE.equals(type)) {
return new EditInput(obj);
} else if (NumberInput.INPUT_TYPE.equals(type)) {
return new NumberInput(obj);
} else if (PasswordInput.INPUT_TYPE.equals(type)) {
return new PasswordInput(obj);
} else if (CheckboxInput.INPUT_TYPE.equals(type)) {

View File

@ -10,6 +10,7 @@ import org.mozilla.gecko.db.BrowserContract.Bookmarks;
import org.mozilla.gecko.db.BrowserContract.Combined;
import org.mozilla.gecko.db.BrowserContract.URLColumns;
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
import org.mozilla.gecko.util.StringUtils;
import android.content.Context;
import android.content.res.TypedArray;
@ -126,9 +127,6 @@ public class HomeListView extends ListView
*/
public static class HomeContextMenuInfo extends AdapterContextMenuInfo {
// URL to Title replacement regex.
private static final String REGEX_URL_TO_TITLE = "^([a-z]+://)?(www\\.)?";
public int bookmarkId;
public int historyId;
public String url;
@ -200,7 +198,8 @@ public class HomeListView extends ListView
}
public String getDisplayTitle() {
return TextUtils.isEmpty(title) ? url.replaceAll(REGEX_URL_TO_TITLE, "") : title;
return TextUtils.isEmpty(title) ?
StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url, StringUtils.UrlFlags.STRIP_HTTPS)) : title;
}
}
}

View File

@ -10,6 +10,7 @@ import org.mozilla.gecko.ThumbnailHelper;
import org.mozilla.gecko.db.BrowserDB.TopSitesCursorWrapper;
import org.mozilla.gecko.db.BrowserDB.URLColumns;
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
import org.mozilla.gecko.util.StringUtils;
import android.content.Context;
import android.content.res.TypedArray;
@ -217,9 +218,6 @@ public class TopBookmarksView extends GridView {
*/
public static class TopBookmarksContextMenuInfo extends AdapterContextMenuInfo {
// URL to Title replacement regex.
private static final String REGEX_URL_TO_TITLE = "^([a-z]+://)?(www\\.)?";
public String url;
public String title;
public boolean isPinned;
@ -237,7 +235,8 @@ public class TopBookmarksView extends GridView {
}
public String getDisplayTitle() {
return TextUtils.isEmpty(title) ? url.replaceAll(REGEX_URL_TO_TITLE, "") : title;
return TextUtils.isEmpty(title) ?
StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url, StringUtils.UrlFlags.STRIP_HTTPS)) : title;
}
}
}

View File

@ -47,7 +47,16 @@ public class StringUtils {
return wasSearchQuery;
}
public static class UrlFlags {
public static final int NONE = 0;
public static final int STRIP_HTTPS = 1;
}
public static String stripScheme(String url) {
return stripScheme(url, UrlFlags.NONE);
}
public static String stripScheme(String url, int flags) {
if (url == null) {
return url;
}
@ -57,6 +66,8 @@ public class StringUtils {
if (url.startsWith("http://")) {
start = 7;
} else if (url.startsWith("https://") && flags == UrlFlags.STRIP_HTTPS) {
start = 8;
}
if (url.endsWith("/")) {

View File

@ -37,8 +37,10 @@
<script type="application/javascript;version=1.8"><![CDATA[
const {classes: Cc, interfaces: Ci, manager: Cm, utils: Cu} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Prompt.jsm");
let gStringBundle = Services.strings.createBundle("chrome://browser/locale/config.properties");
let gCommonBundle = Services.strings.createBundle("chrome://global/locale/commonDialogs.properties");
function dump(a) {
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(a);
@ -144,31 +146,37 @@
}
Services.prefs.setBoolPref(aPref.name, result.value);
} else {
let result = { value: aPref.value };
let text = gStringBundle.formatStringFromName("modifyPref.promptText", [aPref.name], 1);
if (!Services.prompt.prompt(window, title, text, result, null, {}))
return;
if (aPref.type == Ci.nsIPrefBranch.PREF_INT) {
// | 0 converts to integer or 0; - 0 to float or NaN.
// Thus, this check should catch all cases.
let val = result.value | 0;
if (val != result.value - 0) {
let errorTitle = gStringBundle.GetStringFromName("modifyPref.numberErrorTitle");
let errorText = gStringBundle.GetStringFromName("modifyPref.numberErrorText");
Services.prompt.alert(window, errorTitle, errorText);
return;
}
Services.prefs.setIntPref(aPref.name, val);
} else {
let supportsString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
supportsString.data = result.value;
Services.prefs.setComplexValue(aPref.name, Ci.nsISupportsString, supportsString);
}
Services.prefs.savePrefFile(null);
return;
}
Services.prefs.savePrefFile(null);
// If not a boolean, we're a number or string
let p = new Prompt({
window: window,
title: title,
message: gStringBundle.formatStringFromName("modifyPref.promptText", [aPref.name], 1),
buttons: [
gCommonBundle.GetStringFromName("OK"),
gCommonBundle.GetStringFromName("Cancel")
]
});
(aPref.type == Ci.nsIPrefBranch.PREF_INT) ?
p.addNumber({ value: aPref.value, autofocus: true }) :
p.addTextbox({ value: aPref.value, autofocus: true });
p.show(function(result) {
if (result.button == 0) {
if (aPref.type == Ci.nsIPrefBranch.PREF_INT) {
Services.prefs.setIntPref(aPref.name, result.number0);
} else {
let supportsString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
supportsString.data = result.textbox0;
Services.prefs.setComplexValue(aPref.name, Ci.nsISupportsString, supportsString);
}
Services.prefs.savePrefFile(null);
}
});
},
resetPref: function AC_resetPref(aPref) {

View File

@ -78,6 +78,16 @@ Prompt.prototype = {
});
},
addNumber: function(aOptions) {
return this._addInput({
type: "number",
value: aOptions.value,
hint: aOptions.hint,
autofocus: aOptions.autofocus,
id: aOptions.id
});
},
addPassword: function(aOptions) {
return this._addInput({
type: "password",

View File

@ -146,7 +146,7 @@ let tests = {
port.onmessage = function(e) {
if (e.data.topic == "ping") {
try {
importScripts("http://foo.bar/error");
importScripts("http://mochi.test:8888/error");
} catch(ex) {
port.postMessage({topic: "pong", data: ex});
return;