зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1314013 - Allow the bookmarking ui to add a new keyword when the provided postData differs from the existing one. r=adw
MozReview-Commit-ID: FRqwTxNpej --HG-- extra : rebase_source : cba686d1d80a1a3c8dc7bb397fceb57d1a801a05
This commit is contained in:
Родитель
a6f9209af4
Коммит
c276ac7679
|
@ -141,7 +141,17 @@ var gEditItemOverlay = {
|
|||
yield PlacesUtils.keywords.fetch({ url: this._paneInfo.uri.spec },
|
||||
e => entries.push(e));
|
||||
if (entries.length > 0) {
|
||||
this._keyword = newKeyword = entries[0].keyword;
|
||||
// We show an existing keyword if either POST data was not provided, or
|
||||
// if the POST data is the same.
|
||||
let existingKeyword = entries[0].keyword;
|
||||
let postData = this._paneInfo.postData;
|
||||
if (postData) {
|
||||
let sameEntry = entries.find(e => e.postData === postData);
|
||||
existingKeyword = sameEntry ? sameEntry.keyword : "";
|
||||
}
|
||||
if (existingKeyword) {
|
||||
this._keyword = newKeyword = existingKeyword;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._initTextField(this._keywordField, newKeyword);
|
||||
|
|
|
@ -8,7 +8,7 @@ add_task(function* () {
|
|||
url: TEST_URL,
|
||||
}, function* (browser) {
|
||||
// We must wait for the context menu code to build metadata.
|
||||
yield openContextMenuForContentSelector(browser, 'form > input[name="search"]');
|
||||
yield openContextMenuForContentSelector(browser, '#form1 > input[name="search"]');
|
||||
|
||||
yield withBookmarksDialog(true, AddKeywordForSearchField, function* (dialogWin) {
|
||||
let acceptBtn = dialogWin.document.documentElement.getButton("accept");
|
||||
|
@ -47,6 +47,61 @@ add_task(function* () {
|
|||
});
|
||||
});
|
||||
|
||||
add_task(function* reopen_same_field() {
|
||||
yield PlacesUtils.keywords.insert({
|
||||
url: TEST_URL,
|
||||
keyword: "kw",
|
||||
postData: "accenti%3D%E0%E8%EC%F2%F9&search%3D%25s"
|
||||
});
|
||||
registerCleanupFunction(function* () {
|
||||
yield PlacesUtils.keywords.remove("kw");
|
||||
});
|
||||
// Reopening on the same input field should show the existing keyword.
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: TEST_URL,
|
||||
}, function* (browser) {
|
||||
// We must wait for the context menu code to build metadata.
|
||||
yield openContextMenuForContentSelector(browser, '#form1 > input[name="search"]');
|
||||
|
||||
yield withBookmarksDialog(true, AddKeywordForSearchField, function* (dialogWin) {
|
||||
let acceptBtn = dialogWin.document.documentElement.getButton("accept");
|
||||
ok(acceptBtn.disabled, "Accept button is disabled");
|
||||
|
||||
let elt = dialogWin.document.getElementById("editBMPanel_keywordField");
|
||||
is(elt.value, "kw");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
add_task(function* open_other_field() {
|
||||
yield PlacesUtils.keywords.insert({
|
||||
url: TEST_URL,
|
||||
keyword: "kw2",
|
||||
postData: "search%3D%25s"
|
||||
});
|
||||
registerCleanupFunction(function* () {
|
||||
yield PlacesUtils.keywords.remove("kw2");
|
||||
});
|
||||
// Reopening on another field of the same page that has different postData
|
||||
// should not show the existing keyword.
|
||||
yield BrowserTestUtils.withNewTab({
|
||||
gBrowser,
|
||||
url: TEST_URL,
|
||||
}, function* (browser) {
|
||||
// We must wait for the context menu code to build metadata.
|
||||
yield openContextMenuForContentSelector(browser, '#form2 > input[name="search"]');
|
||||
|
||||
yield withBookmarksDialog(true, AddKeywordForSearchField, function* (dialogWin) {
|
||||
let acceptBtn = dialogWin.document.documentElement.getButton("accept");
|
||||
ok(acceptBtn.disabled, "Accept button is disabled");
|
||||
|
||||
let elt = dialogWin.document.getElementById("editBMPanel_keywordField");
|
||||
is(elt.value, "");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getPostDataString(stream) {
|
||||
let sis = Cc["@mozilla.org/scriptableinputstream;1"]
|
||||
.createInstance(Ci.nsIScriptableInputStream);
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
<meta http-equiv="Content-Type" content="text/html;charset=windows-1252">
|
||||
</head>
|
||||
<body>
|
||||
<form method="POST" action="keyword_form.html">
|
||||
<form id="form1" method="POST" action="keyword_form.html">
|
||||
<input type="hidden" name="accenti" value="àèìòù">
|
||||
<input type="text" name="search">
|
||||
</form>
|
||||
<form id="form2" method="POST" action="keyword_form.html">
|
||||
<input type="hidden" name="accenti" value="ùòìèà">
|
||||
<input type="text" name="search">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче