- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / ad_view / display_first_ad / 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 the page running inside an <adview> has the ability to load
6 // and display an image inside an <iframe>.
7
8 function runTests(guestURL) {
9   chrome.test.runTests([
10     function test() {
11       var adview = document.getElementsByTagName("adview")[0];
12
13       adview.addEventListener("loadcommit", function() {
14         adview.contentWindow.postMessage({
15           message: "display-first-ad",
16           publisherData: "data"
17         }, "*");
18       })
19
20       window.addEventListener("message", function(event) {
21         if (event.data.message == "ad-displayed") {
22           console.log("ad-displayed: " + event.data.data.adSize.height);
23           chrome.test.succeed();
24         }
25       })
26
27       adview.setAttribute("src", guestURL);
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 }