android / android/android-test

StrictModeDiskReadViolation from WebViewAssertions

Open
#813 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description
StrictMode$StrictModeDiskReadViolation at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler at androidx.test.espresso.web.assertion.WebViewAssertions$ResultCheckingWebAssertion.checkResult

### Steps to Reproduce
Enable StrictMode.
Run an Espresso test that checks a webview:
```
onWebView().check(webMatches(getCurrentUrl(), containsString("Hello")));
```

### Expected Results
WebView assertion doesn't create a strictmode violation.

### Actual Results
```
StrictMode policy violation: android.os.StrictMode$StrictModeDiskReadViolation: policy=65599 violation=2
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1438)
at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:241)
at java.io.File.isDirectory(File.java:837)
at dalvik.system.DexPathList$Element.findResource(DexPathList.java:690)
at dalvik.system.DexPathList.findResource(DexPathList.java:488)
at dalvik.system.BaseDexClassLoader.findResource(BaseDexClassLoader.java:112)
at java.lang.ClassLoader.getResource(ClassLoader.java:793)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:987)
at java.util.ResourceBundle$RBClassLoader.getResourceAsStream(ResourceBundle.java:512)
at java.util.ResourceBundle$Control$1.run(ResourceBundle.java:2672)
at java.util.ResourceBundle$Control$1.run(ResourceBundle.java:2658)
at java.security.AccessController.doPrivileged(AccessController.java:67)
at java.util.ResourceBundle$Control.newBundle(ResourceBundle.java:2656)
at java.util.ResourceBundle.loadBundle(ResourceBundle.java:1494)
at java.util.ResourceBundle.findBundle(ResourceBundle.java:1458)
at java.util.ResourceBundle.findBundle(ResourceBundle.java:1412)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1354)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:770)
at org.apache.xml.serializer.CharInfo.(CharInfo.java:194)
at org.apache.xml.serializer.CharInfo.(Unknown Source:0)
at org.apache.xml.serializer.CharInfo$1.run(CharInfo.java:465)
at java.security.AccessController.doPrivileged(AccessController.java:41)
at org.apache.xml.serializer.CharInfo.getCharInfoBasedOnPrivilege(CharInfo.java:462)
at org.apache.xml.serializer.CharInfo.getCharInfo(CharInfo.java:498)
at org.apache.xml.serializer.ToXMLStream.(ToXMLStream.java:51)
at java.lang.Class.newInstance(Native Method)
at org.apache.xml.serializer.SerializerFactory.getSerializer(SerializerFactory.java:133)
at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:261)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:330)
at androidx.test.espresso.web.assertion.WebViewAssertions$WebContentResultDescriber.apply(WebViewAssertions.java:153)
at androidx.test.espresso.web.assertion.WebViewAssertions$WebContentResultDescriber.apply(WebViewAssertions.java:141)
at androidx.test.espresso.web.assertion.WebViewAssertions$ResultCheckingWebAssertion.checkResult(WebViewAssertions.java:124)
at androidx.test.espresso.web.assertion.WebAssertion$CheckResultWebAssertion.check(WebAssertion.java:79)
at androidx.test.espresso.ViewInteraction$SingleExecutionViewAssertion.check(ViewInteraction.java:425)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:288)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:272)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
```

### AndroidX Test and Android OS Versions
* Android emulator API 26
* head (67538b5b7143e8bd5b0b857b049ae8b676d66245)

### Link to a public git repo demonstrating the problem:

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with StrictMode enabled and the shown Espresso WebView assertion on an API 26 emulator. Start at androidx.test.espresso.web.assertion.WebViewAssertions$WebContentResultDescriber and ResultCheckingWebAssertion, especially the stack-trace locations around lines 124, 141, and 153. Done means the assertion no longer produces a StrictMode disk-read violation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.