title: What's the true purpose of setJavaScriptCanOpenWindowsAutomatically
body: <p>According to <a href="https://developer.android.com/reference/android/webkit/WebSettings.html#setJavaScriptCanOpenWindowsAutomatically(boolean)" rel="nofollow">Android document</a>:</p>
  
  <blockquote>
    <p>Tells JavaScript to open windows automatically. This applies to the JavaScript function window.open(). The default is false.</p>
  </blockquote>
  
  <p>But I didn't see any different between use or not use this API in my code, window.open works fine in the both cases, so what's the true purpose of this API or my usage is not correct?</p>
  
  <p>My code sample as below:</p>
  
  <pre><code>public class MainActivity extends Activity {
  private WebView mWebView;
  //private Context mContext
  RelativeLayout mParent;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      mParent = new RelativeLayout(MainActivity.this);
      setContentView(mParent);
  
      mWebView = new WebView(MainActivity.this);
      WebSettings settings = mWebView.getSettings();
      settings.setSupportMultipleWindows(true);
      settings.setJavaScriptCanOpenWindowsAutomatically(false);
      settings.setJavaScriptEnabled(true);
      mParent.addView(mWebView);
      mWebView.loadUrl("file:///android_asset/create_window.html");
  
      mWebView.setWebViewClient(new MyWebViewClient());
      mWebView.setWebChromeClient(new WebChromeClient() {
          @Override
          public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg) {
              WebView newWebView = new WebView(view.getContext());
              newWebView.getSettings().setUserAgentString("BBB");
              //newWebView.getSettings().setJavaScriptEnabled(true);
              //newWebView.setWebChromeClient(this);
              newWebView.setWebViewClient(new MyWebViewClient());
              //view.getSettings().setUserAgentString("CCC");
              mParent.addView(newWebView);
              WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
              transport.setWebView(newWebView);
              resultMsg.sendToTarget();
              return true;
          }
  
          @Override
          public void onCloseWindow(WebView window) {
              mParent.removeViewAt(mParent.getChildCount() - 1);
          }
      });
  
  }
  
  private class MyWebViewClient extends WebViewClient {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
          view.loadUrl(url);
          return true;
      }
  
      @Override
      public void onPageStarted(WebView view, String url, Bitmap favicon) {
          super.onPageStarted(view, url, favicon);
  
      }
  
      @Override
      public void onPageFinished(WebView view, final String url) {
          super.onPageFinished(view, url);
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The content of create_window.html as below:</p>
  
  <pre><code>&lt;html&gt;
  &lt;!-- scripts --&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;Create Window&lt;/title&gt;
      &lt;script&gt;
          function
          openURL ()
          {
              alert ("opening window");
              window.open ("http://www.whoishostingthis.com/tools/user-agent/",  "_blank", "width=200,height=100");
          }
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;div&gt;
    &lt;button onclick="openURL()"&gt;open website in new window&lt;/button&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>