mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1244966 - Re-enable testBookmarklets using a simpler test r=margaret
This commit is contained in:
parent
a182a1d524
commit
ec6fe8647c
@ -27,7 +27,7 @@ skip-if = android_version == "10" || android_version == "18"
|
||||
[src/org/mozilla/gecko/tests/testBookmarkFolders.java]
|
||||
# disabled on Android 2.3, bug 979552; on 4.3, bug 1144921
|
||||
skip-if = android_version == "10" || android_version == "18"
|
||||
# [src/org/mozilla/gecko/tests/testBookmarklets.java] # see bug 915350
|
||||
[src/org/mozilla/gecko/tests/testBookmarklets.java]
|
||||
# [src/org/mozilla/gecko/tests/testBookmarkKeyword.java] # see bug 915350
|
||||
[src/org/mozilla/gecko/tests/testBrowserProvider.java]
|
||||
[src/org/mozilla/gecko/tests/testBrowserSearchVisibility.java]
|
||||
|
@ -5,80 +5,42 @@
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import org.mozilla.gecko.Actions;
|
||||
import org.mozilla.gecko.home.HomePager;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.jayway.android.robotium.solo.Condition;
|
||||
|
||||
|
||||
public class testBookmarklets extends AboutHomeTest {
|
||||
public class testBookmarklets extends BaseTest {
|
||||
public void testBookmarklets() {
|
||||
final String url = getAbsoluteUrl(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL);
|
||||
final String title = "alertBookmarklet";
|
||||
final String js = "javascript:alert(12 + .34)";
|
||||
final String js = "javascript:alert(12 + 10)";
|
||||
final String expected = "22";
|
||||
boolean alerted;
|
||||
|
||||
blockForGeckoReady();
|
||||
|
||||
// load a standard page so bookmarklets work
|
||||
inputAndLoadUrl(url);
|
||||
// Waiting for page title to ensure the page is loaded
|
||||
verifyUrlBarTitle(mStringHelper.ROBOCOP_BLANK_PAGE_01_URL);
|
||||
// Load a standard page so bookmarklets work
|
||||
loadUrlAndWait(url);
|
||||
|
||||
// verify that user-entered bookmarklets do *not* work
|
||||
// Verify that user-entered bookmarklets do *not* work
|
||||
enterUrl(js);
|
||||
mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
|
||||
alerted = waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return mSolo.searchButton("OK", true) || mSolo.searchText("12.34", true);
|
||||
return mSolo.searchButton("OK", true) || mSolo.searchText(expected, true);
|
||||
}
|
||||
}, 3000);
|
||||
mAsserter.is(alerted, false, "Alert was not shown for user-entered bookmarklet");
|
||||
|
||||
// add the bookmarklet to the database. there's currently no way to
|
||||
// add this using the UI, so we go through the content provider.
|
||||
mDatabaseHelper.addMobileBookmark(title, js);
|
||||
|
||||
// Open about:home in the Bookmarks page
|
||||
openAboutHomeTab(AboutHomeTabs.BOOKMARKS);
|
||||
|
||||
ListView bookmarks = findListViewWithTag(HomePager.LIST_TAG_BOOKMARKS);
|
||||
mAsserter.is(waitForNonEmptyListToLoad(bookmarks), true, "list is properly loaded");
|
||||
|
||||
int width = mDriver.getGeckoWidth();
|
||||
int height = mDriver.getGeckoHeight();
|
||||
|
||||
// Scroll down so that the bookmarks list has more items on screen.
|
||||
mActions.drag(width / 2, width / 2, height - 10, height / 2);
|
||||
|
||||
// Verify that bookmarklets clicked in awesomescreen work
|
||||
boolean found = false;
|
||||
for (int i = bookmarks.getHeaderViewsCount(); i < bookmarks.getAdapter().getCount(); i++) {
|
||||
Cursor c = (Cursor)bookmarks.getItemAtPosition(i);
|
||||
String aUrl = c.getString(c.getColumnIndexOrThrow("url"));
|
||||
if (aUrl.equals(js)) {
|
||||
found = true;
|
||||
mAsserter.is(1, 1, "Found bookmarklet added to bookmarks: " + js);
|
||||
mSolo.clickOnView(bookmarks.getChildAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
mAsserter.is(found, true, "Found the bookmark: " + js + " and clicked on it");
|
||||
}
|
||||
|
||||
// Verify that non-user-entered bookmarklets do work
|
||||
loadUrl(js);
|
||||
alerted = waitForCondition(new Condition() {
|
||||
@Override
|
||||
public boolean isSatisfied() {
|
||||
return mSolo.searchButton("OK", true) && mSolo.searchText("12.34", true);
|
||||
return mSolo.searchButton("OK", true) && mSolo.searchText(expected, true);
|
||||
}
|
||||
}, 3000);
|
||||
mAsserter.is(alerted, true, "Alert was shown for clicked bookmarklet");
|
||||
|
||||
// remove the bookmarklet
|
||||
mDatabaseHelper.deleteBookmark(js);
|
||||
mAsserter.is(alerted, true, "Alert was shown for bookmarklet");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user