Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5dc0c825 authored by Elliott Slaughter's avatar Elliott Slaughter
Browse files

Add setXSSAuditorEnabled support in WebSettings.

Change-Id: I6f74589b28960b91093acf8219a55e98f93b1881
parent 75d41c96
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ public class WebSettings {
    private boolean         mDomStorageEnabled = false;
    private boolean         mWorkersEnabled = false;  // only affects V8.
    private boolean         mGeolocationEnabled = true;
    private boolean         mXSSAuditorEnabled = false;
    // HTML5 configuration parameters
    private long            mAppCacheMaxSize = Long.MAX_VALUE;
    private String          mAppCachePath = "";
@@ -1233,6 +1234,17 @@ public class WebSettings {
        }
    }

    /**
     * Sets whether XSS Auditor is enabled.
     * @param flag Whether XSS Auditor should be enabled.
     */
    public synchronized void setXSSAuditorEnabled(boolean flag) {
        if (mXSSAuditorEnabled != flag) {
            mXSSAuditorEnabled = flag;
            postSync();
        }
    }

    /**
     * Return true if javascript is enabled. <b>Note: The default is false.</b>
     * @return True if javascript is enabled.
+10 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
    private static final int SET_GEOLOCATION_PERMISSION = 43;
    private static final int OVERRIDE_PREFERENCE = 44;
    private static final int LAYOUT_DUMP_CHILD_FRAMES_TEXT = 45;
    private static final int SET_XSS_AUDITOR_ENABLED = 46;
    
    CallbackProxy(EventSender eventSender, 
            LayoutTestController layoutTestController) {
@@ -278,6 +279,11 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
            boolean value = msg.getData().getBoolean("value");
            mLayoutTestController.overridePreference(key, value);
            break;

        case SET_XSS_AUDITOR_ENABLED:
            mLayoutTestController.setXSSAuditorEnabled(
                msg.arg1 == 1 ? true : false);
            break;
        }
    }

@@ -507,4 +513,8 @@ public class CallbackProxy extends Handler implements EventSender, LayoutTestCon
        message.getData().putBoolean("value", value);
        message.sendToTarget();
    }

    public void setXSSAuditorEnabled(boolean flag) {
        obtainMessage(SET_XSS_AUDITOR_ENABLED, flag ? 1 : 0, 0).sendToTarget();
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -68,4 +68,7 @@ public interface LayoutTestController {
    public void setGeolocationPermission(boolean allow);

    public void overridePreference(String key, boolean value);

    // For XSSAuditor tests
    public void setXSSAuditorEnabled(boolean flag);
}
+4 −0
Original line number Diff line number Diff line
@@ -497,6 +497,10 @@ public class TestShellActivity extends Activity implements LayoutTestController
        }
    }

    public void setXSSAuditorEnabled (boolean flag) {
        mWebView.getSettings().setXSSAuditorEnabled(flag);
    }

    private final WebViewClient mViewClient = new WebViewClient(){
        @Override
        public void onPageFinished(WebView view, String url) {