File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -279,6 +279,7 @@ public void onPageFinished(String url) {
279279 }
280280
281281 if (!shouldInjectJavaScript (url )) {
282+ mAccessibilityScriptInjected = false ;
282283 toggleFallbackAccessibilityInjector (true );
283284 return ;
284285 }
@@ -291,6 +292,23 @@ public void onPageFinished(String url) {
291292 mAccessibilityScriptInjected = true ;
292293 }
293294
295+ /**
296+ * Adjusts the accessibility injection state to reflect changes in the
297+ * JavaScript enabled state.
298+ *
299+ * @param enabled Whether JavaScript is enabled.
300+ */
301+ public void updateJavaScriptEnabled (boolean enabled ) {
302+ if (enabled ) {
303+ addAccessibilityApisIfNecessary ();
304+ } else {
305+ removeAccessibilityApisIfNecessary ();
306+ }
307+
308+ // We have to reload the page after adding or removing APIs.
309+ mWebView .reload ();
310+ }
311+
294312 /**
295313 * Toggles the non-JavaScript method for handling accessibility.
296314 *
Original file line number Diff line number Diff line change @@ -1135,6 +1135,7 @@ public synchronized void setJavaScriptEnabled(boolean flag) {
11351135 if (mJavaScriptEnabled != flag ) {
11361136 mJavaScriptEnabled = flag ;
11371137 postSync ();
1138+ mWebView .updateJavaScriptEnabled (flag );
11381139 }
11391140 }
11401141
Original file line number Diff line number Diff line change @@ -1626,6 +1626,12 @@ void updateMultiTouchSupport(Context context) {
16261626 mZoomManager .updateMultiTouchSupport (context );
16271627 }
16281628
1629+ void updateJavaScriptEnabled (boolean enabled ) {
1630+ if (isAccessibilityEnabled ()) {
1631+ getAccessibilityInjector ().updateJavaScriptEnabled (enabled );
1632+ }
1633+ }
1634+
16291635 private void init () {
16301636 OnTrimMemoryListener .init (mContext );
16311637 mWebView .setWillNotDraw (false );
You can’t perform that action at this time.
0 commit comments