зеркало из https://github.com/mozilla/gecko-dev.git
Merge central to inbound
This commit is contained in:
Коммит
faacb3c669
|
@ -20,6 +20,7 @@ _BROWSER_FILES = \
|
|||
browser_newtab_reset.js \
|
||||
browser_newtab_tabsync.js \
|
||||
browser_newtab_unpin.js \
|
||||
browser_newtab_bug722273.js \
|
||||
browser_newtab_bug723102.js \
|
||||
browser_newtab_bug723121.js \
|
||||
head.js \
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const NOW = Date.now() * 1000;
|
||||
const URL = "http://fake-site.com/";
|
||||
|
||||
let tmp = {};
|
||||
Cu.import("resource:///modules/NewTabUtils.jsm", tmp);
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
|
||||
let {NewTabUtils, Sanitizer} = tmp;
|
||||
|
||||
let bhist = Cc["@mozilla.org/browser/global-history;2"]
|
||||
.getService(Ci.nsIBrowserHistory);
|
||||
|
||||
function runTests() {
|
||||
clearHistory();
|
||||
fillHistory();
|
||||
yield addNewTabPageTab();
|
||||
|
||||
is(cells[0].site.url, URL, "first site is our fake site");
|
||||
|
||||
let page = {
|
||||
update: function () {
|
||||
executeSoon(TestRunner.next);
|
||||
},
|
||||
|
||||
observe: function () {}
|
||||
};
|
||||
|
||||
NewTabUtils.allPages.register(page);
|
||||
yield clearHistory();
|
||||
|
||||
NewTabUtils.allPages.unregister(page);
|
||||
ok(!cells[0].site, "the fake site is gone");
|
||||
}
|
||||
|
||||
function fillHistory() {
|
||||
let uri = makeURI(URL);
|
||||
for (let i = 59; i > 0; i--)
|
||||
bhist.addPageWithDetails(uri, "fake site", NOW - i * 60 * 1000000);
|
||||
}
|
||||
|
||||
function clearHistory() {
|
||||
let s = new Sanitizer();
|
||||
s.prefDomain = "privacy.cpd.";
|
||||
|
||||
let prefs = gPrefService.getBranch(s.prefDomain);
|
||||
prefs.setBoolPref("history", true);
|
||||
prefs.setBoolPref("downloads", false);
|
||||
prefs.setBoolPref("cache", false);
|
||||
prefs.setBoolPref("cookies", false);
|
||||
prefs.setBoolPref("formdata", false);
|
||||
prefs.setBoolPref("offlineApps", false);
|
||||
prefs.setBoolPref("passwords", false);
|
||||
prefs.setBoolPref("sessions", false);
|
||||
prefs.setBoolPref("siteSettings", false);
|
||||
|
||||
s.sanitize();
|
||||
}
|
|
@ -129,10 +129,11 @@ function addNewTabPageTab() {
|
|||
cw = browser.contentWindow;
|
||||
|
||||
if (NewTabUtils.allPages.enabled) {
|
||||
cells = cw.gGrid.cells;
|
||||
|
||||
// Continue when the link cache has been populated.
|
||||
NewTabUtils.links.populateCache(TestRunner.next);
|
||||
NewTabUtils.links.populateCache(function () {
|
||||
cells = cw.gGrid.cells;
|
||||
executeSoon(TestRunner.next);
|
||||
});
|
||||
} else {
|
||||
TestRunner.next();
|
||||
}
|
||||
|
@ -246,6 +247,8 @@ function unpinCell(aCell) {
|
|||
*/
|
||||
function simulateDrop(aDropTarget, aDragSource) {
|
||||
let event = {
|
||||
clientX: 0,
|
||||
clientY: 0,
|
||||
dataTransfer: {
|
||||
mozUserCancelled: false,
|
||||
setData: function () null,
|
||||
|
|
|
@ -732,8 +732,26 @@ CssRuleView.prototype = {
|
|||
}.bind(this);
|
||||
|
||||
this._createEditors();
|
||||
|
||||
// When creating a new property, we fake the normal property
|
||||
// editor behavior (focusing a property's value after entering its
|
||||
// name) by responding to the name's blur event, creating the
|
||||
// value editor, and grabbing focus to the value editor. But if
|
||||
// focus has already moved to another document, we won't be able
|
||||
// to move focus to the new editor.
|
||||
// Create a focusable item at the end of the editors to catch these
|
||||
// cases.
|
||||
this._focusBackstop = createChild(this.element, "div", {
|
||||
tabindex: 0,
|
||||
});
|
||||
this._backstopHandler = function() {
|
||||
// If this item is actually focused long enough to get the focus
|
||||
// event, allow focus to move on out of this document.
|
||||
moveFocus(this.doc.defaultView, FOCUS_FORWARD);
|
||||
}.bind(this);
|
||||
this._focusBackstop.addEventListener("focus", this._backstopHandler, false);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Update the rules for the currently highlighted element.
|
||||
*/
|
||||
|
@ -762,6 +780,12 @@ CssRuleView.prototype = {
|
|||
this._clearRules();
|
||||
this._viewedElement = null;
|
||||
this._elementStyle = null;
|
||||
|
||||
if (this._focusBackstop) {
|
||||
this._focusBackstop.removeEventListener("focus", this._backstopHandler, false);
|
||||
this._backstopHandler = null;
|
||||
this._focusBackstop = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -845,7 +869,6 @@ RuleEditor.prototype = {
|
|||
|
||||
this.openBrace = createChild(header, "span", {
|
||||
class: "ruleview-ruleopen",
|
||||
tabindex: "0",
|
||||
textContent: " {"
|
||||
});
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_ruleview_manipulation.js \
|
||||
browser_ruleview_override.js \
|
||||
browser_ruleview_ui.js \
|
||||
browser_ruleview_focus.js \
|
||||
browser_bug705707_is_content_stylesheet.js \
|
||||
browser_bug722196_property_view_media_queries.js \
|
||||
browser_bug722196_rule_view_media_queries.js \
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Test that focus doesn't leave the style editor when adding a property
|
||||
// (bug 719916)
|
||||
|
||||
let doc;
|
||||
let stylePanel;
|
||||
|
||||
function waitForRuleView(aCallback)
|
||||
{
|
||||
if (InspectorUI.ruleView) {
|
||||
aCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
let ruleViewFrame = InspectorUI.getToolIframe(InspectorUI.ruleViewObject);
|
||||
ruleViewFrame.addEventListener("load", function(evt) {
|
||||
ruleViewFrame.removeEventListener(evt.type, arguments.callee, true);
|
||||
executeSoon(function() {
|
||||
aCallback();
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
|
||||
function waitForEditorFocus(aParent, aCallback)
|
||||
{
|
||||
aParent.addEventListener("focus", function onFocus(evt) {
|
||||
if (evt.target.inplaceEditor) {
|
||||
aParent.removeEventListener("focus", onFocus, true);
|
||||
let editor = evt.target.inplaceEditor;
|
||||
executeSoon(function() {
|
||||
aCallback(editor);
|
||||
});
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
function openRuleView()
|
||||
{
|
||||
Services.obs.addObserver(function onOpened() {
|
||||
Services.obs.removeObserver(onOpened,
|
||||
InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
|
||||
// Highlight a node.
|
||||
let node = content.document.getElementsByTagName("h1")[0];
|
||||
InspectorUI.inspectNode(node);
|
||||
InspectorUI.stopInspecting();
|
||||
|
||||
// Open the rule view sidebar.
|
||||
waitForRuleView(testFocus);
|
||||
|
||||
InspectorUI.showSidebar();
|
||||
InspectorUI.ruleButton.click();
|
||||
|
||||
testFocus();
|
||||
}, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
|
||||
InspectorUI.openInspectorUI();
|
||||
}
|
||||
|
||||
function testFocus()
|
||||
{
|
||||
let ruleViewFrame = InspectorUI.getToolIframe(InspectorUI.ruleViewObject);
|
||||
let brace = ruleViewFrame.contentDocument.querySelectorAll(".ruleview-ruleclose")[0];
|
||||
waitForEditorFocus(brace.parentNode, function onNewElement(aEditor) {
|
||||
aEditor.input.value = "color";
|
||||
waitForEditorFocus(brace.parentNode, function onEditingValue(aEditor) {
|
||||
// If we actually get this focus we're ok.
|
||||
ok(true, "We got focus.");
|
||||
aEditor.input.value = "green";
|
||||
|
||||
// If we've retained focus, pressing return will start a new editor.
|
||||
// If not, we'll wait here until we time out.
|
||||
waitForEditorFocus(brace.parentNode, function onNewEditor(aEditor) {
|
||||
aEditor.input.blur();
|
||||
finishTest();
|
||||
});
|
||||
EventUtils.sendKey("return");
|
||||
});
|
||||
EventUtils.sendKey("return");
|
||||
});
|
||||
|
||||
brace.focus();
|
||||
}
|
||||
|
||||
function finishUp()
|
||||
{
|
||||
doc = stylePanel = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
}
|
||||
|
||||
function test()
|
||||
{
|
||||
waitForExplicitFinish();
|
||||
gBrowser.selectedTab = gBrowser.addTab();
|
||||
gBrowser.selectedBrowser.addEventListener("load", function(evt) {
|
||||
gBrowser.selectedBrowser.removeEventListener(evt.type, arguments.callee, true);
|
||||
doc = content.document;
|
||||
doc.title = "Rule View Test";
|
||||
waitForFocus(openRuleView, content);
|
||||
}, true);
|
||||
|
||||
content.location = "data:text/html,<h1>Some header text</h1>";
|
||||
}
|
|
@ -121,8 +121,6 @@ let Storage = {
|
|||
// want any data from private browsing to show up.
|
||||
PinnedLinks.resetCache();
|
||||
BlockedLinks.resetCache();
|
||||
|
||||
Pages.update();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -187,11 +185,6 @@ let AllPages = {
|
|||
*/
|
||||
_pages: [],
|
||||
|
||||
/**
|
||||
* Tells whether we already added a preference observer.
|
||||
*/
|
||||
_observing: false,
|
||||
|
||||
/**
|
||||
* Cached value that tells whether the New Tab Page feature is enabled.
|
||||
*/
|
||||
|
@ -203,12 +196,7 @@ let AllPages = {
|
|||
*/
|
||||
register: function AllPages_register(aPage) {
|
||||
this._pages.push(aPage);
|
||||
|
||||
// Add the preference observer if we haven't already.
|
||||
if (!this._observing) {
|
||||
this._observing = true;
|
||||
Services.prefs.addObserver(PREF_NEWTAB_ENABLED, this, true);
|
||||
}
|
||||
this._addObserver();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -238,6 +226,14 @@ let AllPages = {
|
|||
Services.prefs.setBoolPref(PREF_NEWTAB_ENABLED, !!aEnabled);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the number of registered New Tab Pages (i.e. the number of open
|
||||
* about:newtab instances).
|
||||
*/
|
||||
get length() {
|
||||
return this._pages.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates all currently active pages but the given one.
|
||||
* @param aExceptPage The page to exclude from updating.
|
||||
|
@ -264,6 +260,15 @@ let AllPages = {
|
|||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a preference observer and turns itself into a no-op after the first
|
||||
* invokation.
|
||||
*/
|
||||
_addObserver: function AllPages_addObserver() {
|
||||
Services.prefs.addObserver(PREF_NEWTAB_ENABLED, this, true);
|
||||
this._addObserver = function () {};
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
};
|
||||
|
@ -512,6 +517,8 @@ let Links = {
|
|||
this._links = aLinks;
|
||||
executeCallbacks();
|
||||
}.bind(this));
|
||||
|
||||
this._addObserver();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -544,7 +551,32 @@ let Links = {
|
|||
*/
|
||||
resetCache: function Links_resetCache() {
|
||||
this._links = [];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Implements the nsIObserver interface to get notified about browser history
|
||||
* sanitization.
|
||||
*/
|
||||
observe: function Links_observe(aSubject, aTopic, aData) {
|
||||
// Make sure to update open about:newtab instances. If there are no opened
|
||||
// pages we can just wait for the next new tab to populate the cache again.
|
||||
if (AllPages.length && AllPages.enabled)
|
||||
this.populateCache(function () { AllPages.update() }, true);
|
||||
else
|
||||
this._links = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a sanitization observer and turns itself into a no-op after the first
|
||||
* invokation.
|
||||
*/
|
||||
_addObserver: function Links_addObserver() {
|
||||
Services.obs.addObserver(this, "browser:purge-session-history", true);
|
||||
this._addObserver = function () {};
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -459,7 +459,7 @@ class ShutdownLeakLogger(object):
|
|||
DOM windows (that are still around after test suite shutdown, despite running
|
||||
the GC) to the tests that created them and prints leak statistics.
|
||||
"""
|
||||
MAX_LEAK_COUNT = 123
|
||||
MAX_LEAK_COUNT = 120
|
||||
|
||||
def __init__(self, logger):
|
||||
self.logger = logger
|
||||
|
|
|
@ -487,7 +487,7 @@ SmsDatabaseService.prototype = {
|
|||
// In first place, we retrieve the keys that match the filter.startDate
|
||||
// and filter.endDate search criteria.
|
||||
let timeKeyRange = null;
|
||||
if (!filter.startDate != null && filter.endDate != null) {
|
||||
if (filter.startDate != null && filter.endDate != null) {
|
||||
timeKeyRange = IDBKeyRange.bound(filter.startDate.getTime(),
|
||||
filter.endDate.getTime());
|
||||
} else if (filter.startDate != null) {
|
||||
|
|
|
@ -2612,10 +2612,12 @@ let GsmPDUHelper = {
|
|||
* @param langShiftTable
|
||||
* single shift table string.
|
||||
*
|
||||
* @return encoded length in septets.
|
||||
*
|
||||
* @note that the algorithm used in this function must match exactly with
|
||||
* #writeStringAsSeptets.
|
||||
*/
|
||||
_calculateLangEncodedLength: function _calculateLangEncodedLength(message, langTable, langShiftTable) {
|
||||
_calculateLangEncodedSeptets: function _calculateLangEncodedSeptets(message, langTable, langShiftTable) {
|
||||
let length = 0;
|
||||
for (let msgIndex = 0; msgIndex < message.length; msgIndex++) {
|
||||
let septet = langTable.indexOf(message.charAt(msgIndex));
|
||||
|
@ -2686,17 +2688,17 @@ let GsmPDUHelper = {
|
|||
options.userDataHeaderLength = 0;
|
||||
|
||||
let needUCS2 = true;
|
||||
let minUserDataLength = Number.MAX_VALUE;
|
||||
let minUserDataSeptets = Number.MAX_VALUE;
|
||||
for (let i = 0; i < this.enabledGsmTableTuples.length; i++) {
|
||||
let [langIndex, langShiftIndex] = this.enabledGsmTableTuples[i];
|
||||
|
||||
const langTable = PDU_NL_LOCKING_SHIFT_TABLES[langIndex];
|
||||
const langShiftTable = PDU_NL_SINGLE_SHIFT_TABLES[langShiftIndex];
|
||||
|
||||
let length = this._calculateLangEncodedLength(options.body,
|
||||
langTable,
|
||||
langShiftTable);
|
||||
if (length < 0) {
|
||||
let bodySeptets = this._calculateLangEncodedSeptets(options.body,
|
||||
langTable,
|
||||
langShiftTable);
|
||||
if (bodySeptets < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2709,23 +2711,19 @@ let GsmPDUHelper = {
|
|||
}
|
||||
|
||||
// Calculate full user data length, note the extra byte is for header len
|
||||
let userDataLength = length + (headerLen ? headerLen + 1 : 0);
|
||||
if (userDataLength >= minUserDataLength) {
|
||||
let headerSeptets = Math.ceil((headerLen ? headerLen + 1 : 0) * 8 / 7);
|
||||
let userDataSeptets = bodySeptets + headerSeptets;
|
||||
if (userDataSeptets >= minUserDataSeptets) {
|
||||
continue;
|
||||
}
|
||||
|
||||
needUCS2 = false;
|
||||
minUserDataLength = userDataLength;
|
||||
minUserDataSeptets = userDataSeptets;
|
||||
|
||||
options.encodedBodyLength = length;
|
||||
options.encodedBodyLength = bodySeptets;
|
||||
options.userDataHeaderLength = headerLen;
|
||||
options.langIndex = langIndex;
|
||||
options.langShiftIndex = langShiftIndex;
|
||||
|
||||
if (userDataLength <= options.body.length) {
|
||||
// Found minimum user data length already
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (needUCS2) {
|
||||
|
|
|
@ -55,10 +55,10 @@ add_test(function test_nl_single_shift_tables_validity() {
|
|||
});
|
||||
|
||||
/**
|
||||
* Verify GsmPDUHelper#_calculateLangEncodedLength() and
|
||||
* Verify GsmPDUHelper#_calculateLangEncodedSeptets() and
|
||||
* GsmPDUHelper#writeStringAsSeptets() algorithm match each other.
|
||||
*/
|
||||
add_test(function test_GsmPDUHelper__calculateLangEncodedLength() {
|
||||
add_test(function test_GsmPDUHelper__calculateLangEncodedSeptets() {
|
||||
let worker = newWorker({
|
||||
postRILMessage: function fakePostRILMessage(data) {
|
||||
// Do nothing
|
||||
|
@ -78,9 +78,9 @@ add_test(function test_GsmPDUHelper__calculateLangEncodedLength() {
|
|||
|
||||
function do_check_calc(str, expectedCalcLen, lst, sst) {
|
||||
do_check_eq(expectedCalcLen,
|
||||
helper._calculateLangEncodedLength(str,
|
||||
PDU_NL_LOCKING_SHIFT_TABLES[lst],
|
||||
PDU_NL_SINGLE_SHIFT_TABLES[sst]));
|
||||
helper._calculateLangEncodedSeptets(str,
|
||||
PDU_NL_LOCKING_SHIFT_TABLES[lst],
|
||||
PDU_NL_SINGLE_SHIFT_TABLES[sst]));
|
||||
|
||||
helper.resetOctetWritten();
|
||||
helper.writeStringAsSeptets(str, 0, lst, sst);
|
||||
|
@ -193,6 +193,21 @@ add_test(function test_GsmPDUHelper_calculateUserDataLength() {
|
|||
test_calc("A", [PDU_DCS_MSG_CODING_7BITS_ALPHABET, 1, 3, 1, 0], [[1, 0], [2, 4]]);
|
||||
test_calc("A", [PDU_DCS_MSG_CODING_7BITS_ALPHABET, 1, 3, 1, 0], [[2, 4], [1, 0]]);
|
||||
|
||||
// Test Bug 733981
|
||||
// - Case 1, headerLen is in octets, not septets. "\\" is defined in default
|
||||
// single shift table and Portuguese locking shift table. The original code
|
||||
// will add headerLen 7(octets), which should be 8(septets), to calculated
|
||||
// cost and gets 14, which should be 15 in total for the first run. As for
|
||||
// the second run, it will be undoubtedly 14 in total. With correct fix,
|
||||
// the best choice should be the second one.
|
||||
test_calc("\\\\\\\\\\\\\\",
|
||||
[PDU_DCS_MSG_CODING_7BITS_ALPHABET, 14, 0, 0, 0], [[3, 1], [0, 0]]);
|
||||
// - Case 2, possible early return non-best choice. The original code will
|
||||
// get total cost 6 in the first run and returns immediately. With correct
|
||||
// fix, the best choice should be the second one.
|
||||
test_calc(ESCAPE + ESCAPE + ESCAPE + ESCAPE + ESCAPE + "\\",
|
||||
[PDU_DCS_MSG_CODING_7BITS_ALPHABET, 2, 0, 0, 0], [[3, 0], [0, 0]]);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
|
@ -390,8 +405,8 @@ function test_receiving_7bit_alphabets(lst, sst) {
|
|||
for (let i = 0; i < text.length;) {
|
||||
let len = Math.min(70, text.length - i);
|
||||
let expected = text.substring(i, i + len);
|
||||
let septets = helper._calculateLangEncodedLength(expected, langTable,
|
||||
langShiftTable);
|
||||
let septets = helper._calculateLangEncodedSeptets(expected, langTable,
|
||||
langShiftTable);
|
||||
let rawBytes = get7bitRawBytes(expected);
|
||||
let pdu = compose7bitPdu(lst, sst, rawBytes, septets);
|
||||
add_test_receiving_sms(expected, pdu);
|
||||
|
|
Загрузка…
Ссылка в новой задаче