Add tests for did-change-theme-color event

This commit is contained in:
Brian R. Bondy 2015-12-22 17:16:31 -05:00
parent 11b2015535
commit 29b00ae0d6
5 changed files with 38 additions and 8 deletions

View file

@ -490,13 +490,11 @@ void WebContents::MediaPaused() {
} }
void WebContents::DidChangeThemeColor(SkColor theme_color) { void WebContents::DidChangeThemeColor(SkColor theme_color) {
char themeColor[8] = { 0 }; std::string hex_theme_color = base::StringPrintf("#%02X%02X%02X",
snprintf(themeColor, sizeof(themeColor), SkColorGetR(theme_color),
"#%02X%02X%02X", SkColorGetG(theme_color),
SkColorGetR(theme_color), SkColorGetB(theme_color));
SkColorGetG(theme_color), Emit("did-change-theme-color", hex_theme_color);
SkColorGetB(theme_color));
Emit("did-change-theme-color", themeColor);
} }
void WebContents::DocumentLoadedInFrame( void WebContents::DocumentLoadedInFrame(

View file

@ -235,6 +235,22 @@ Returns:
Emitted when a result is available for Emitted when a result is available for
[`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request. [`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request.
### Event: 'media-started-playing'
Emitted when media starts playing.
### Event: 'media-paused'
Emitted when media is paused or done playing.
### Event: 'did-change-theme-color'
Emitted when a page's theme color changes. This is usually due to encountering a meta tag:
```html
<meta name='theme-color' content='#ff0000'>
```
## Instance Methods ## Instance Methods
The `webContents` object has the following instance methods: The `webContents` object has the following instance methods:

View file

@ -647,4 +647,6 @@ Emitted when media is paused or done playing.
Emitted when a page's theme color changes. This is usually due to encountering a meta tag: Emitted when a page's theme color changes. This is usually due to encountering a meta tag:
<meta name='theme-color' content='#ff0000'> ```html
<meta name='theme-color' content='#ff0000'>
```

7
spec/fixtures/pages/theme-color.html vendored Normal file
View file

@ -0,0 +1,7 @@
<html>
<head>
<meta name="theme-color" content="#ffeedd">
</head>
<body>
</body>
</html>

View file

@ -406,3 +406,10 @@ describe '<webview> tag', ->
webview.addEventListener 'did-finish-load', listener2 webview.addEventListener 'did-finish-load', listener2
webview.src = "file://#{fixtures}/pages/content.html" webview.src = "file://#{fixtures}/pages/content.html"
document.body.appendChild webview document.body.appendChild webview
describe 'did-change-theme-color event', ->
it 'emits when theme color changes', (done) ->
webview.addEventListener 'did-change-theme-color', (e) ->
done()
webview.src = "file://#{fixtures}/pages/theme-color.html"
document.body.appendChild webview