Bug 1273341 - Don't attempt to sync tabs with very long URLs. r=markh

Now with a test.

MozReview-Commit-ID: 9QehGKLbqLA

--HG--
extra : amend_source : 412b4b8b1efaf0797ee2272cacbb122e1b18918f
This commit is contained in:
Richard Newman 2016-05-16 21:39:53 -07:00
Родитель 8a2fbc6805
Коммит bc22d2f478
2 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -165,6 +165,11 @@ TabStore.prototype = {
continue;
}
if (current.url.length >= (MAX_UPLOAD_BYTES - 1000)) {
this._log.trace("Skipping over-long URL.");
continue;
}
// The element at `index` is the current page. Previous URLs were
// previously visited URLs; subsequent URLs are in the 'forward' stack,
// which we can't represent in Sync, so we truncate here.

Просмотреть файл

@ -1,6 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines/tabs.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
@ -23,11 +24,12 @@ add_test(function test_getOpenURLs() {
_("Test getOpenURLs.");
let [engine, store] = getMocks();
let urls = ["http://bar.com", "http://foo.com", "http://foobar.com"];
function threeURLs() {
let superLongURL = "http://" + (new Array(MAX_UPLOAD_BYTES).join("w")) + ".com/";
let urls = ["http://bar.com", "http://foo.com", "http://foobar.com", superLongURL];
function fourURLs() {
return urls.pop();
}
store.getWindowEnumerator = mockGetWindowEnumerator.bind(this, threeURLs, 1, 3);
store.getWindowEnumerator = mockGetWindowEnumerator.bind(this, fourURLs, 1, 4);
let matches;
@ -40,6 +42,10 @@ add_test(function test_getOpenURLs() {
matches = openurlsset.has("http://barfoo.com");
ok(!matches);
_(" test matching works (too long)");
matches = openurlsset.has(superLongURL);
ok(!matches);
run_next_test();
});