Skip to content

Commit

Permalink
Bug 1612608 - [2.1] Adjust tests to account for missing multiprocess …
Browse files Browse the repository at this point in the history
…session setting. r=geckoview-reviewers,aklotz

Differential Revision: https://phabricator.services.mozilla.com/D62079

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Eugen Sawin committed Feb 12, 2020
1 parent 83e385a commit 7f5b959
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ open class BaseSessionTest(noErrorCollector: Boolean = false) {
InstrumentationRegistry.getInstrumentation().targetContext.resources.assets
.open(path.removePrefix("/assets/")).readBytes()

val GeckoSession.isRemote
get() = this.settings.getUseMultiprocess()

fun createTestUrl(path: String) = GeckoSessionTestRule.TEST_ENDPOINT + path

fun GeckoSession.loadTestPath(path: String) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1150,32 +1150,6 @@ class NavigationDelegateTest : BaseSessionTest() {
equalTo(NEW_SESSION_HTML_PATH))
}
@Setting(key = Setting.Key.USE_MULTIPROCESS, value = "false")
@Test fun onNewSession_openRemoteFromNonRemote() {
// Disable popup blocker.
sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false))

// Ensure a non-remote page can open a remote page, as needed by some tests.
assertThat("Opening session should be non-remote",
mainSession.settings.useMultiprocess,
equalTo(false))

mainSession.loadTestPath(HELLO_HTML_PATH)
mainSession.waitForPageStop()

val newSession = delegateNewSession(
GeckoSessionSettings.Builder(mainSession.settings)
.useMultiprocess(true)
.build())

mainSession.evaluateJS("window.open('http://example.com'); true")
newSession.waitForPageStop()

assertThat("window.opener should be set",
newSession.evaluateJS("window.opener != null") as Boolean,
equalTo(true))
}

@Test fun onNewSession_supportNoOpener() {
// Disable popup blocker.
sessionRule.setPrefsUntilTestEnd(mapOf("dom.disable_open_during_load" to false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class RemoteGeckoService : Service() {
}
CMD_CRASH_CONTENT_NATIVE -> {
val settings = GeckoSessionSettings.Builder()
.useMultiprocess(true)
.build()
val session = GeckoSession(settings)
session.open(runtime!!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,19 @@ public class GeckoSessionTestRule implements TestRule {
* under test. Can be used on classes or methods. Note that the settings values must
* be string literals regardless of the type of the settings.
* <p>
* Disable e10s for a particular test:
* Enable tracking protection for a particular test:
* <pre>
* &#64;Setting.List(&#64;Setting(key = Setting.Key.USE_MULTIPROCESS,
* &#64;Setting.List(&#64;Setting(key = Setting.Key.USE_TRACKING_PROTECTION,
* value = "false"))
* &#64;Test public void test() { ... }
* </pre>
* <p>
* Use multiple settings:
* <pre>
* &#64;Setting.List({&#64;Setting(key = Setting.Key.USE_MULTIPROCESS,
* value = "false"),
* &#64;Setting.List({&#64;Setting(key = Setting.Key.USE_PRIVATE_MODE,
* value = "true"),
* &#64;Setting(key = Setting.Key.USE_TRACKING_PROTECTION,
* value = "true")})
* value = "false")})
* </pre>
*/
@Target({ElementType.METHOD, ElementType.TYPE})
Expand All @@ -193,7 +193,6 @@ enum Key {
DISPLAY_MODE,
ALLOW_JAVASCRIPT,
SCREEN_ID,
USE_MULTIPROCESS,
USE_PRIVATE_MODE,
USE_TRACKING_PROTECTION,
FULL_ACCESSIBILITY_TREE;
Expand Down Expand Up @@ -760,7 +759,6 @@ private static Set<Class<?>> getDefaultDelegates() {

public GeckoSessionTestRule() {
mDefaultSettings = new GeckoSessionSettings.Builder()
.useMultiprocess(env.isMultiprocess())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class RuntimeCreator {
public static final int TEST_SUPPORT_ERROR = 2;
private static final String LOGTAG = "RuntimeCreator";

private static final Environment env = new Environment();
private static GeckoRuntime sRuntime;
public static AtomicInteger sTestSupport = new AtomicInteger(0);
public static WebExtension sTestSupportExtension;
Expand Down Expand Up @@ -147,6 +148,7 @@ public static GeckoRuntime getRuntime() {
}

final GeckoRuntimeSettings runtimeSettings = new GeckoRuntimeSettings.Builder()
.useMultiprocess(env.isMultiprocess())
.arguments(new String[]{"-purgecaches"})
.extras(InstrumentationRegistry.getArguments())
.remoteDebuggingEnabled(true)
Expand Down Expand Up @@ -209,7 +211,6 @@ private static void shutdownRuntimeInternal(final long timeoutMillis) {
* down any extant GeckoRuntime, thus ensuring only one GeckoRuntime is active at once.
*/
public static void shutdownRuntime() {
final Environment env = new Environment();
// It takes a while to shutdown an existing runtime in debug builds, so
// we double the timeout for this method.
final long timeoutMillis = 2 * env.getDefaultTimeoutMillis();
Expand Down

0 comments on commit 7f5b959

Please sign in to comment.