Emit("crashed");
}
+void WebContents::DocumentLoadedInFrame(
+ content::RenderFrameHost* render_frame_host) {
+ if (!render_frame_host->GetParent())
+ Emit("dom-ready");
+}
+
void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) {
bool is_main_frame = !render_frame_host->GetParent();
// content::WebContentsObserver:
void RenderViewDeleted(content::RenderViewHost*) override;
void RenderProcessGone(base::TerminationStatus status) override;
+ void DocumentLoadedInFrame(
+ content::RenderFrameHost* render_frame_host) override;
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
const GURL& validated_url) override;
void DidFailLoad(content::RenderFrameHost* render_frame_host,
'did-stop-loading'
'did-get-response-details'
'did-get-redirect-request'
+ 'dom-ready'
'console-message'
'new-window'
'close'
'did-get-response-details': ['status', 'newUrl', 'originalUrl',
'httpResponseCode', 'requestMethod', 'referrer']
'did-get-redirect-request': ['oldUrl', 'newUrl', 'isMainFrame']
+ 'dom-ready': []
'console-message': ['level', 'message', 'line', 'sourceId']
'new-window': ['url', 'frameName', 'disposition']
'close': []
Emitted when a redirect was received while requesting a resource.
+### Event: 'dom-ready'
+
+* `event` Event
+
+Emitted when document in the given frame is loaded.
+
### Event: 'page-favicon-updated'
* `event` Event
Fired when a redirect was received while requesting a resource.
+### dom-ready
+
+Fired when document in the given frame is loaded.
+
### page-title-set
* `title` String
fs = require 'fs'
path = require 'path'
remote = require 'remote'
+http = require 'http'
+url = require 'url'
BrowserWindow = remote.require 'browser-window'
assert.equal url, 'https://www.github.com/'
done()
w.loadUrl "file://#{fixtures}/pages/will-navigate.html"
+
+ describe 'dom-ready event', ->
+ it 'emits when document is loaded', (done) ->
+ server = http.createServer (req, res) ->
+ action = url.parse(req.url, true).pathname
+ if action == '/logo.png'
+ img = fs.readFileSync(path.join(fixtures, 'assets', 'logo.png'))
+ res.writeHead(200, {'Content-Type': 'image/png'})
+ setTimeout ->
+ res.end(img, 'binary')
+ , 2000
+ server.close()
+ server.listen 62542, '127.0.0.1'
+ remote.require('ipc').on 'dom-ready', (e, state) ->
+ assert.equal state, 'interactive'
+ done()
+ w.webContents.on 'did-finish-load', ->
+ w.close()
+ w.loadUrl "file://#{fixtures}/pages/f.html"
--- /dev/null
+<html>
+<body>
+<img src='http://127.0.0.1:62542/logo.png' />
+<script type="text/javascript" charset="utf-8">
+ var remote = require('remote')
+ remote.getCurrentWindow().webContents.on('dom-ready', function() {
+ require('ipc').send('dom-ready', document.readyState);
+ })
+</script>
+</body>
+</html>