It's required for testing the BrowserWindow class.
*prevent_default = Emit("page-title-updated", &args);
}
+void Window::OnLoadingStateChanged(bool is_loading) {
+ base::ListValue args;
+ args.AppendBoolean(is_loading);
+ Emit("loading-state-changed", &args);
+}
+
void Window::WillCloseWindow(bool* prevent_default) {
*prevent_default = Emit("close");
}
// Implementations of NativeWindowObserver.
virtual void OnPageTitleUpdated(bool* prevent_default,
const std::string& title) OVERRIDE;
+ virtual void OnLoadingStateChanged(bool is_loading) OVERRIDE;
virtual void WillCloseWindow(bool* prevent_default) OVERRIDE;
virtual void OnWindowClosed() OVERRIDE;
virtual void OnWindowBlur() OVERRIDE;
virtual void OnPageTitleUpdated(bool* prevent_default,
const std::string& title) {}
- // Called when the window is starting or is done loading a resource.
+ // Called when the window is starting or is done loading a page.
virtual void OnLoadingStateChanged(bool is_loading) {}
// Called when the window is gonna closed.
Emitted when the document changed its title, calling `event.preventDefault()` would prevent the native window's title to change.
+### Event: 'loading-state-changed'
+
+* `event` Event
+* `isLoading` Boolean
+
+Emitted when the window is starting or is done loading a page.
+
### Event: 'close'
* `event` Event
### BrowserWindow.reloadIgnoringCache()
-Reloads current window and ignores cache.
\ No newline at end of file
+Reloads current window and ignores cache.
assert.equal String(content), 'close'
done()
w.loadUrl 'file://' + path.join(fixtures, 'api', 'close.html')
+
+ describe 'BrowserWindow.loadUrl(url)', ->
+ it 'should emit loading-state-changed event', (done) ->
+ w = new BrowserWindow(show: false)
+ count = 0
+ w.on 'loading-state-changed', (event, isLoading) ->
+ if count == 0
+ assert.equal isLoading, true
+ else if count == 1
+ assert.equal isLoading, false
+ done()
+ else
+ assert false
+
+ ++count
+ w.loadUrl 'about:blank'