add spec and docs

This commit is contained in:
Robo 2015-08-27 06:57:03 +05:30
parent 5189147021
commit 150b540e72
4 changed files with 53 additions and 0 deletions

View file

@ -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. If "on", the guest page will have web security disabled.
### partition
```html
<webview src="https://github.com" partition="persist:github"></webview>
<webview src="http://electron.atom.io" partition="electron"></webview>
```
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 ## Methods
The `webview` tag has the following methods: The `webview` tag has the following methods:

View file

@ -0,0 +1,5 @@
<script>
window.localStorage.setItem('test', 'one');
const item = window.localStorage.getItem('test');
console.log([item, window.localStorage.length].join(' '));
</script>

View file

@ -0,0 +1,4 @@
<script>
const item = window.localStorage.getItem('test');
console.log([item, window.localStorage.length].join(' '));
</script>

View file

@ -154,6 +154,33 @@ describe '<webview> tag', ->
webview.src = "data:text/html;base64,#{encoded}" webview.src = "data:text/html;base64,#{encoded}"
document.body.appendChild webview 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', -> describe 'new-window event', ->
it 'emits when window.open is called', (done) -> it 'emits when window.open is called', (done) ->
webview.addEventListener 'new-window', (e) -> webview.addEventListener 'new-window', (e) ->