mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 729485 - Test for content permissions prompts. r=mbrubeck,kats
This commit is contained in:
parent
98b1afeb0d
commit
cce4894d5f
@ -18,6 +18,22 @@ class PixelTest extends BaseTest {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final PaintedSurface reloadAndPaint() {
|
||||||
|
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
||||||
|
|
||||||
|
mActions.sendSpecialKey(Actions.SpecialKey.MENU);
|
||||||
|
mSolo.waitForText("Reload");
|
||||||
|
mSolo.clickOnText("Reload");
|
||||||
|
|
||||||
|
paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
|
||||||
|
PaintedSurface p = mDriver.getPaintedSurface();
|
||||||
|
if (p == null) {
|
||||||
|
mAsserter.ok(p != null, "checking that painted surface loaded",
|
||||||
|
"painted surface loaded");
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
protected final PaintedSurface waitForPaint(Actions.RepeatedEventExpecter expecter) {
|
protected final PaintedSurface waitForPaint(Actions.RepeatedEventExpecter expecter) {
|
||||||
expecter.blockUntilClear(PAINT_CLEAR_DELAY);
|
expecter.blockUntilClear(PAINT_CLEAR_DELAY);
|
||||||
PaintedSurface p = mDriver.getPaintedSurface();
|
PaintedSurface p = mDriver.getPaintedSurface();
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
[testPasswordEncrypt]
|
[testPasswordEncrypt]
|
||||||
[testFormHistory]
|
[testFormHistory]
|
||||||
[testBrowserProvider]
|
[testBrowserProvider]
|
||||||
|
[testPermissions]
|
||||||
# [testJarReader] # see bug 738890
|
# [testJarReader] # see bug 738890
|
||||||
|
|
||||||
# Used for Talos, please don't use in mochitest
|
# Used for Talos, please don't use in mochitest
|
||||||
|
17
mobile/android/base/tests/robocop_geolocation.html
Normal file
17
mobile/android/base/tests/robocop_geolocation.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<html>
|
||||||
|
<title>Geolocation Test Page</title>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
function clb(position) {
|
||||||
|
// Show a green background if permission is granted
|
||||||
|
document.body.style.background = "#008000";
|
||||||
|
}
|
||||||
|
function err(error) {
|
||||||
|
// Show a red background if permission is denied
|
||||||
|
if (error.code == error.PERMISSION_DENIED)
|
||||||
|
document.body.style.background = "#FF0000";
|
||||||
|
}
|
||||||
|
navigator.geolocation.getCurrentPosition(clb, err, {timeout: 0});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
55
mobile/android/base/tests/testPermissions.java.in
Normal file
55
mobile/android/base/tests/testPermissions.java.in
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#filter substitution
|
||||||
|
package @ANDROID_PACKAGE_NAME@.tests;
|
||||||
|
|
||||||
|
import @ANDROID_PACKAGE_NAME@.*;
|
||||||
|
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class testPermissions extends PixelTest {
|
||||||
|
private PaintedSurface mPaintedSurface;
|
||||||
|
private Actions.RepeatedEventExpecter mPaintExpecter;
|
||||||
|
|
||||||
|
public void testPermissions() {
|
||||||
|
setTestType("mochitest");
|
||||||
|
mActions.expectGeckoEvent("Gecko:Ready").blockForEvent();
|
||||||
|
|
||||||
|
geolocationTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void geolocationTest() {
|
||||||
|
// Test geolocation notification
|
||||||
|
mPaintedSurface = loadAndPaint(getAbsoluteUrl("/robocop/robocop_geolocation.html"));
|
||||||
|
mSolo.waitForText("wants your location");
|
||||||
|
|
||||||
|
// Uncheck the "Don't ask again for this site" checkbox
|
||||||
|
ArrayList<CheckBox> checkBoxes = mSolo.getCurrentCheckBoxes();
|
||||||
|
mAsserter.ok(checkBoxes.size() == 1, "checkbox count", "only one checkbox visible");
|
||||||
|
mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked");
|
||||||
|
mSolo.clickOnCheckBox(0);
|
||||||
|
mAsserter.ok(!mSolo.isCheckBoxChecked(0), "checkbox not checked", "checkbox is not checked");
|
||||||
|
|
||||||
|
// Test "Share" button functionality with unchecked checkbox
|
||||||
|
mPaintExpecter = mActions.expectPaint();
|
||||||
|
mSolo.clickOnText("Share");
|
||||||
|
mPaintedSurface = waitForPaint(mPaintExpecter);
|
||||||
|
mAsserter.ispixel(mPaintedSurface.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
||||||
|
|
||||||
|
// Re-trigger geolocation notification
|
||||||
|
reloadAndPaint();
|
||||||
|
mSolo.waitForText("wants your location");
|
||||||
|
|
||||||
|
// Make sure the checkbox is checked this time
|
||||||
|
mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked");
|
||||||
|
|
||||||
|
// Test "Share" button functionality with checked checkbox
|
||||||
|
mPaintExpecter = mActions.expectPaint();
|
||||||
|
mSolo.clickOnText("Share");
|
||||||
|
mPaintedSurface = waitForPaint(mPaintExpecter);
|
||||||
|
mAsserter.ispixel(mPaintedSurface.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
||||||
|
|
||||||
|
// When we reload the page, location should be automatically shared
|
||||||
|
mPaintedSurface = reloadAndPaint();
|
||||||
|
mAsserter.ispixel(mPaintedSurface.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user