- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / ad_view / properties_exposed / chrometest.js
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.
4
5 // This test checks that <adview> attributes are also exposed as properties
6 // (with the same name and value).
7
8 function runTests(guestURL) {
9   chrome.test.runTests([
10     function test() {
11       var adview = document.getElementsByTagName('adview')[0];
12       var adnetwork = adview.getAttribute('ad-network');
13
14       adview.setAttribute('src', guestURL);
15
16       // Timeout is necessary to give the mutation observers a chance to fire.
17       // http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1622.html
18       setTimeout(function() {
19         chrome.test.assertEq(guestURL, adview.getAttribute('src'));
20         chrome.test.assertEq(guestURL, adview['src']);
21
22         chrome.test.assertEq(adnetwork, adview.getAttribute('ad-network'));
23         chrome.test.assertEq(adnetwork, adview['ad-network']);
24
25         console.log("Properties verified.");
26         chrome.test.succeed();
27       }, 0);
28     }
29   ]);
30 }
31
32 window.onload = function() {
33   chrome.test.getConfig(function(config) {
34     var guestURL = 'http://localhost:' + config.testServer.port +
35       '/extensions/platform_apps/ad_view/ad_network_site/testsdk.html';
36     runTests(guestURL);
37   });
38 }