mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 461820 - prevent accessing searchbar history from content (tests) r=dolske
--HG-- extra : rebase_source : c83545f7fa62353bad8cdd783fdd09626b9a23e0
This commit is contained in:
parent
ecb8f8c2ac
commit
8386f3e604
@ -8,6 +8,7 @@ this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/Chr
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
var searchEntries = ["test", "More Text", "Some Text"];
|
||||
var searchBar = BrowserSearch.searchBar;
|
||||
var searchButton = document.getAnonymousElementByAttribute(searchBar,
|
||||
"anonid", "search-go-button");
|
||||
@ -177,10 +178,29 @@ function test() {
|
||||
is(gBrowser.tabs.length, preTabNo, "RightClick did not open new tab");
|
||||
is(gBrowser.currentURI.spec, "about:blank", "RightClick did nothing");
|
||||
|
||||
finalize();
|
||||
testSearchHistory();
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
function testSearchHistory() {
|
||||
var textbox = searchBar._textbox;
|
||||
for (var i = 0; i < searchEntries.length; i++) {
|
||||
let exists = textbox._formHistSvc.entryExists(textbox.searchParam, searchEntries[i]);
|
||||
ok(exists, "form history entry '" + searchEntries[i] + "' should exist");
|
||||
}
|
||||
testAutocomplete();
|
||||
}
|
||||
|
||||
function testAutocomplete() {
|
||||
var popup = searchBar.textbox.popup;
|
||||
popup.addEventListener("popupshowing", function() {
|
||||
checkMenuEntries(searchEntries);
|
||||
finalize();
|
||||
popup.removeEventListener("popupshowing", this, false);
|
||||
}, false);
|
||||
searchBar.textbox.showHistoryPopup();
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
searchBar.value = "";
|
||||
while (gBrowser.tabs.length != 1) {
|
||||
@ -211,5 +231,26 @@ function test() {
|
||||
buttonArg, null);
|
||||
aTarget.dispatchEvent(event);
|
||||
}
|
||||
|
||||
// modified from toolkit/components/satchel/test/test_form_autocomplete.html
|
||||
function checkMenuEntries(expectedValues) {
|
||||
var actualValues = getMenuEntries();
|
||||
is(actualValues.length, expectedValues.length, "Checking length of expected menu");
|
||||
for (var i = 0; i < expectedValues.length; i++)
|
||||
is(actualValues[i], expectedValues[i], "Checking menu entry #"+i);
|
||||
}
|
||||
|
||||
function getMenuEntries() {
|
||||
var entries = [];
|
||||
var autocompleteMenu = searchBar.textbox.popup;
|
||||
// Could perhaps pull values directly from the controller, but it seems
|
||||
// more reliable to test the values that are actually in the tree?
|
||||
var column = autocompleteMenu.tree.columns[0];
|
||||
var numRows = autocompleteMenu.tree.view.rowCount;
|
||||
for (var i = 0; i < numRows; i++) {
|
||||
entries.push(autocompleteMenu.tree.view.getValueAt(i, column));
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,12 @@ Form History test: form field autocomplete
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- normal, basic form (with fieldname='searchbar-history') -->
|
||||
<form id="form12" onsubmit="return false;">
|
||||
<input type="text" name="searchbar-history">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<pre id="test">
|
||||
@ -121,6 +127,7 @@ fh.addEntry("field6", "value");
|
||||
fh.addEntry("field7", "value");
|
||||
fh.addEntry("field8", "value");
|
||||
fh.addEntry("field9", "value");
|
||||
fh.addEntry("searchbar-history", "blacklist test");
|
||||
|
||||
// All these non-implemeted types might need autocomplete tests in the future.
|
||||
var todoTypes = [ "datetime", "date", "month", "week", "time", "datetime-local",
|
||||
@ -720,13 +727,28 @@ function runTest(testNum) {
|
||||
ok(true, "oninput should have been received");
|
||||
ok(event.bubbles, "input event should bubble");
|
||||
ok(event.cancelable, "input event should be cancelable");
|
||||
SimpleTest.finish();
|
||||
}, false);
|
||||
|
||||
doKey("down");
|
||||
checkForm("");
|
||||
doKey("return");
|
||||
checkForm("value1");
|
||||
testNum = 599;
|
||||
break;
|
||||
|
||||
case 600:
|
||||
// check we don't show autocomplete for searchbar-history
|
||||
input = $_(12, "searchbar-history");
|
||||
|
||||
// Trigger autocomplete popup
|
||||
checkForm("");
|
||||
restoreForm();
|
||||
doKey("down");
|
||||
break;
|
||||
|
||||
case 601:
|
||||
checkMenuEntries([]);
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
|
||||
default:
|
||||
|
@ -165,6 +165,12 @@
|
||||
<button type='submit'>Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- Don't save values if the input name is 'searchbar-history' -->
|
||||
<form id="form24" onsubmit="return checkSubmit(24);">
|
||||
<input type='text' name='searchbar-history'>
|
||||
<button type='submit'>Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- ===== Things that should be saved ===== -->
|
||||
|
||||
<!-- Form 100 is submitted into an iframe, not declared here. -->
|
||||
@ -328,6 +334,7 @@ function startTest() {
|
||||
$_(20, "test1").value = "dontSaveThis";
|
||||
$_(22, "test1").value = "dontSaveThis";
|
||||
$_(23, "test1").value = "dontSaveThis";
|
||||
$_(24, "searchbar-history").value = "dontSaveThis";
|
||||
|
||||
$_(101, "test1").value = "savedValue";
|
||||
$_(102, "test2").value = "savedValue";
|
||||
@ -365,7 +372,7 @@ function checkSubmit(formNum) {
|
||||
|
||||
// Check for expected storage state.
|
||||
switch (formNum) {
|
||||
// Test 1-23 should not save anything.
|
||||
// Test 1-24 should not save anything.
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
@ -389,6 +396,7 @@ function checkSubmit(formNum) {
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
case 24:
|
||||
ok(!fh.hasEntries, "checking for empty storage");
|
||||
break;
|
||||
case 100:
|
||||
@ -470,7 +478,7 @@ function checkSubmit(formNum) {
|
||||
|
||||
// End the test at the last form.
|
||||
if (formNum == 110) {
|
||||
is(numSubmittedForms, 34, "Ensuring all forms were submitted.");
|
||||
is(numSubmittedForms, 35, "Ensuring all forms were submitted.");
|
||||
Services.obs.removeObserver(checkObserver, "satchel-storage-changed");
|
||||
SimpleTest.finish();
|
||||
return false; // return false to cancel current form submission
|
||||
@ -488,7 +496,7 @@ function checkSubmit(formNum) {
|
||||
checkObserver.waitForChecks(function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var nextFormNum = formNum == 23 ? 100 : (formNum + 1);
|
||||
var nextFormNum = formNum == 24 ? 100 : (formNum + 1);
|
||||
|
||||
// Submit the next form. Special cases are Forms 21 and 100, which happen
|
||||
// from an HTTPS domain in an iframe.
|
||||
|
Loading…
Reference in New Issue
Block a user