1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 config.IS_CHROME_TEST = true;
7 config.IS_JS_ONLY_GUEST = true;
8 config.TEST_DIR = 'execute_code';
10 var executeCodeTests = {};
13 var run = function() {
14 var container = document.createElement('div');
15 container.id = 'webview-tag-container';
16 document.body.appendChild(container);
18 chrome.test.getConfig(function(chromeConfig) {
19 window.console.log('getConfig: ' + chromeConfig);
20 utils.setUp(chromeConfig, config);
22 embedder.loadGuest(function(webview) {
24 window.console.log('bootstrap got embedder.loadGuest');
25 chrome.test.runTests([
26 executeCodeTests.testInsertCSS
29 LOG('embedder.onPostMessageReceived, data[0] = ' + data[0]);
30 if (data[0] == 'style') {
31 var propertyName = data[1];
36 chrome.test.assertEq('background-color', propertyName);
37 chrome.test.assertEq('rgba(0, 0, 0, 0)', value);
38 testBackgroundColorAfterCSSInjection();
42 chrome.test.assertEq('background-color', propertyName);
43 chrome.test.assertEq('rgb(255, 0, 0)', value);
44 chrome.test.succeed();
56 var testBackgroundColorAfterCSSInjection = function() {
57 LOG('testBackgroundColorAfterCSSInjection');
58 g_webview.insertCSS({file: 'execute_code/guest.css'}, function (results) {
59 // Verify that the background color is now red after injecting
61 LOG('testBackgroundColorAfterCSSInjection second postMessage send');
62 g_webview.contentWindow.postMessage(
63 JSON.stringify(['get-style', 'background-color']), '*');
67 executeCodeTests.testInsertCSS = function testInsertCSS() {
68 // Test the background color before CSS injection. Verify that the background
69 // color is indeed white.
70 g_webview.contentWindow.postMessage(
71 JSON.stringify(['get-style', 'background-color']), '*');