diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 6b64a0269c52..ec8529655272 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -131,6 +131,23 @@ page is loaded, use the `setUserAgent` method to change the user agent. If "on", the guest page will have web security disabled. +### partition + +```html + + +``` + +Sets the storage partition used by the `webview`. If the storage partition ID starts with `persist:`, +the `webview` will use a persistent storage partition available to all `webview` in the app with +the same storage partition ID. If the ID is unset or if there is no `persist:` prefix, the `webview` will +use an in-memory storage partition. By assigning the same partition ID, multiple `webview` +can share the same storage partition. + +This value can only be modified before the first navigation, since the storage partition of an active +renderer process cannot change. Subsequent attempts to modify the value will fail with a +DOM exception. + ## Methods The `webview` tag has the following methods: diff --git a/spec/fixtures/pages/partition/one.html b/spec/fixtures/pages/partition/one.html new file mode 100644 index 000000000000..765f721883f3 --- /dev/null +++ b/spec/fixtures/pages/partition/one.html @@ -0,0 +1,5 @@ + diff --git a/spec/fixtures/pages/partition/two.html b/spec/fixtures/pages/partition/two.html new file mode 100644 index 000000000000..ad22c341df95 --- /dev/null +++ b/spec/fixtures/pages/partition/two.html @@ -0,0 +1,4 @@ + diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index 6eb391ac9483..ae8cd5d45579 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -154,6 +154,33 @@ describe ' tag', -> webview.src = "data:text/html;base64,#{encoded}" document.body.appendChild webview + describe 'partition attribute', -> + isolatedWebview = null + beforeEach -> + isolatedWebview = new WebView + + afterEach -> + document.body.removeChild isolatedWebview + + it 'isolates storage for different id', (done) -> + listener = (e) -> + document.body.appendChild isolatedWebview + webview.removeEventListener 'did-finish-load', listener + listener2 = (e) -> + assert.equal e.message, "one 1" + webview.removeEventListener 'console-message', listener2 + listener3 = (e) -> + assert.equal e.message, " 0" + isolatedWebview.removeEventListener 'console-message', listener3 + done() + webview.addEventListener 'did-finish-load', listener + webview.addEventListener 'console-message', listener2 + webview.src = "file://#{fixtures}/pages/partition/one.html" + isolatedWebview.addEventListener 'console-message', listener3 + isolatedWebview.setAttribute 'partition', 'test' + isolatedWebview.src = "file://#{fixtures}/pages/partition/two.html" + document.body.appendChild webview + describe 'new-window event', -> it 'emits when window.open is called', (done) -> webview.addEventListener 'new-window', (e) ->