Repository: bokeh/bokeh

Issue:
Embedding a server plot will override the window title
![screen shot 2016-10-12 at 12 42 59 pm](https://cloud.githubusercontent.com/assets/2198981/19321040/6d0ff2bc-9079-11e6-8c26-ffde884896ac.png)

Embedding a server plot (using bokeh.embed.autoload_server, but I haven't tried other configurations including static plots) into a web page will override the window.title.

This should be configurable and off by default or not present.



Discussion:
I'm fine with it just not setting the title on `autoload_server`


Resolving patch:
diff --git a/bokeh/embed.py b/bokeh/embed.py
--- a/bokeh/embed.py
+++ b/bokeh/embed.py
@@ -400,10 +400,14 @@ def autoload_server(model, app_path="/", session_id=None, url="default"):
             a ``<script>`` tag that will execute an autoload script
             loaded from the Bokeh Server
 
-    .. note:: It is a very bad idea to use the same ``session_id``
-        for every page load; you are likely to create scalability
-        and security problems. So ``autoload_server()`` should be
-        called again on each page load.
+    .. note::
+        Bokeh apps embedded using ``autoload_server`` will NOT set the browser
+        window title.
+
+    .. warning::
+        It is a very bad idea to use the same ``session_id`` for every page
+        load; you are likely to create scalability and security problems. So
+        ``autoload_server()`` should be called again on each page load.
 
     '''
 
diff --git a/bokeh/server/views/autoload_js_handler.py b/bokeh/server/views/autoload_js_handler.py
--- a/bokeh/server/views/autoload_js_handler.py
+++ b/bokeh/server/views/autoload_js_handler.py
@@ -37,7 +37,7 @@ def get(self, *args, **kwargs):
         websocket_url = self.application.websocket_url_for_request(self.request, self.bokeh_websocket_path)
 
         # TODO: yes, this should resuse code from bokeh.embed more directly
-        render_items = [dict(sessionid=session.id, elementid=element_id, use_for_title=True)]
+        render_items = [dict(sessionid=session.id, elementid=element_id, use_for_title=False)]
         script = _script_for_render_items(None, render_items, websocket_url=websocket_url, wrap_script=False)
 
         js = AUTOLOAD_JS.render(


Test patch:
diff --git a/bokeh/server/tests/test_server.py b/bokeh/server/tests/test_server.py
--- a/bokeh/server/tests/test_server.py
+++ b/bokeh/server/tests/test_server.py
@@ -282,6 +282,19 @@ def extract_sessionid_from_json(html):
     match = sessionid_in_json.search(html)
     return match.group(1)
 
+# examples:
+# "sessionid" : "NzlNoPfEYJahnPljE34xI0a5RSTaU1Aq1Cx5"
+# 'sessionid':'NzlNoPfEYJahnPljE34xI0a5RSTaU1Aq1Cx5'
+use_for_title_in_json = re.compile("""["']use_for_title["'] *: *(false|true)""")
+def extract_use_for_title_from_json(html):
+    from six import string_types
+    if not isinstance(html, string_types):
+        import codecs
+        html = codecs.decode(html, 'utf-8')
+    match = use_for_title_in_json.search(html)
+    return match.group(1)
+
+
 def autoload_url(server):
     return url(server) + \
         "autoload.js?bokeh-protocol-version=1.0&bokeh-autoload-element=foo"
@@ -306,6 +319,18 @@ def test__autocreate_session_autoload():
         assert 1 == len(sessions)
         assert sessionid == sessions[0].id
 
+def test__no_set_title_autoload():
+    application = Application()
+    with ManagedServerLoop(application) as server:
+        sessions = server.get_sessions('/')
+        assert 0 == len(sessions)
+
+        response = http_get(server.io_loop,
+                            autoload_url(server))
+        js = response.body
+        use_for_title = extract_use_for_title_from_json(js)
+        assert use_for_title == "false"
+
 def test__autocreate_session_doc():
     application = Application()
     with ManagedServerLoop(application) as server: