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 @@ -1122,6 +1122,7 @@ public synchronized void setJavaScriptEnabled(boolean flag) {
11221122 if (mJavaScriptEnabled != flag ) {
11231123 mJavaScriptEnabled = flag ;
11241124 postSync ();
1125+ mWebView .updateJavaScriptEnabled (flag );
11251126 }
11261127 }
11271128
Original file line number Diff line number Diff line change @@ -1633,6 +1633,12 @@ void updateMultiTouchSupport(Context context) {
16331633 mZoomManager .updateMultiTouchSupport (context );
16341634 }
16351635
1636+ void updateJavaScriptEnabled (boolean enabled ) {
1637+ if (isAccessibilityInjectionEnabled ()) {
1638+ getAccessibilityInjector ().updateJavaScriptEnabled (enabled );
1639+ }
1640+ }
1641+
16361642 private void init () {
16371643 OnTrimMemoryListener .init (mContext );
16381644 mWebView .setWillNotDraw (false );
You can’t perform that action at this time.
0 commit comments