New issue
Advanced search Search tips

Issue 617951 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 620857
Owner: ----
Closed: Jun 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

AwContents.onPause causes un-pauses the javascript timers

Reported by mkrasow...@opera.com, Jun 7 2016

Issue description

Steps to reproduce the problem:
1. Add below testcase to chromium/src/android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java

2. Run the testcase with out/Release/bin/run_android_webview_test_apk -f WebViewModalDialogOverrideTest\#testAwContentsOnPauseDoesNotResumeJsTimers

-- <Java> ------------------------------------
    @SmallTest
    @Feature({"AndroidWebView"})
    public void testAwContentsOnPauseDoesNotResumeJsTimers() throws Throwable {
        final String alertText = "Hello World!";

        final AtomicBoolean callbackCalled = new AtomicBoolean(false);
        // Returning true from the callback should not show a dialog.
        TestAwContentsClient client = new TestAwContentsClient() {
            @Override
            public void handleJsAlert(String url, String message, JsResultReceiver res) {
                callbackCalled.set(true);
                res.confirm();
                assertEquals(alertText, message);
            }
        };
        AwTestContainerView view = createAwTestContainerViewOnMainSync(client);
        final AwContents awContents = view.getAwContents();

        enableJavaScriptOnUiThread(awContents);
        loadDataSync(awContents, client.getOnPageFinishedHelper(),
                EMPTY_PAGE, "text/html", false);
        JSUtils.executeJavaScriptAndWaitForResult(this, awContents,
                client.getOnEvaluateJavaScriptResultHelper(),
                "setTimeout(function(){alert('" + alertText + "');},1000)");

        // added pause timers
        getInstrumentation().runOnMainSync(new Runnable() {
            @Override
            public void run() {
                awContents.pauseTimers();
                awContents.onPause();
            }
        });

        SystemClock.sleep(2000);
        assertFalse(callbackCalled.get());
    }
-- </Java> ------------------------------------

2. testcase fails

What is the expected behavior?
Testcase should not fail.

What went wrong?
The awContents.onPause() call is causing 
the mContentViewCore.onHide() call, which un-pauses the JS timers.

Which is bad. I think.

Did this work before? N/A 

Chrome version: 49.0.2623.110  Channel: n/a
OS Version: 
Flash Version: not important

Test is low-quality, since it contains SystemClock.sleep 'n stuff, but it shows the problem.
 
Components: Mobile>WebView

Comment 2 by boliu@chromium.org, Jun 13 2016

Labels: Needs-Feedback
executeJavaScriptAndWaitForResult is synchronous, the pauseTimers/onPause calls have no affect on the state of callbackCalled

Comment 3 by boliu@chromium.org, Jun 13 2016

wait, js does setTimeout.. uhh..

Comment 4 by boliu@chromium.org, Jun 13 2016

test passed for me on trunk..

Comment 5 by boliu@chromium.org, Jun 13 2016

You mention chrome 49.0.2623.110, even though this is webview. Are you complaining specifically about that version?

Comment 6 by boliu@chromium.org, Jun 16 2016

Mergedinto: 620857
Status: Duplicate (was: Unconfirmed)
assume duplicate, that reporter is responding
Sorry for no-res, indeed the bug is not reproducible on master.
The 49.0.2623.110 is the exact tag on which I have reproduced the bug.

Sign in to add a comment