Chromium Code Reviews| Index: chrome/test/data/extensions/platform_apps/ad_view/invalid_ad_network/chrometest.js |
| diff --git a/chrome/test/data/extensions/platform_apps/ad_view/invalid_ad_network/chrometest.js b/chrome/test/data/extensions/platform_apps/ad_view/invalid_ad_network/chrometest.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c4c6a78fa4ec5f700f851414af98eb31d6c77e6c |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/platform_apps/ad_view/invalid_ad_network/chrometest.js |
| @@ -0,0 +1,77 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// This test checks an invalid "ad-network" value (i.e. not whitelisted) |
| +// is ignored. |
| + |
| +var adview1 = "adview1"; |
| +var adview2 = "adview2"; |
| +var adview3 = "adview3"; |
| + |
| +/** |
| + * Verify setting invalid ad-network value is ignored in immediate Javascript |
| + * code (i.e. before document is fully loaded) on a static <adview> element. |
| + */ |
| +function runTest1() { |
| + var adview = document.getElementById(adview1); |
| + |
| + adview.setAttribute("ad-network", "invalidAdNetwork"); |
| + |
| + // Note: The assertion has to happen in a callback function because of the |
| + // way mutation observer events are processed. See |
| + // http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1622.html |
| + setTimeout(function() { |
| + chrome.test.assertEq("", adview.getAttribute("ad-network")); |
| + console.log("test1 succeeded."); |
| + }, 0); |
| +} |
| + |
| +/** |
| + * Verify setting invalid ad-network value is ignored at "document load" time. |
| + */ |
| +function runTest2() { |
| + var adview = document.createElement("adview"); |
| + adview.id = adview2; |
| + document.body.appendChild(adview); |
| + |
| + adview.setAttribute("ad-network", "invalidAdNetwork2"); |
| + |
| + // Note: The assertion has to happen in a callback function because of the |
| + // way mutation observer events are processed. See |
| + // http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1622.html |
| + setTimeout(function() { |
| + chrome.test.assertEq("", adview.getAttribute("ad-network")); |
| + console.log("test2 succeeded."); |
| + }, 0); |
| +} |
| + |
| +/** |
| + * Verify setting invalid ad-network value is ignored even after document |
| + * is fully loaded. |
| + */ |
| +function runTest3() { |
| + setTimeout(function() { |
|
benwells
2013/04/03 02:40:03
I think you are avoiding chrome.runTests so can en
rpaquay
2013/04/03 18:30:05
In this case, I was using "setTimeout" in "runTest
benwells
2013/04/04 04:33:52
OK, I see. Thanks for adding the comment, they rea
rpaquay
2013/04/05 16:12:08
I see what you mean. I made a change that should e
|
| + var adview = document.createElement("adview"); |
| + adview.id = adview3; |
| + document.body.appendChild(adview); |
| + |
| + adview.setAttribute("ad-network", "invalidAdNetwork3"); |
| + |
| + // Note: The assertion has to happen in a callback function because of the |
| + // way mutation observer events are processed. See |
| + // http://lists.w3.org/Archives/Public/public-webapps/2011JulSep/1622.html |
| + setTimeout(function() { |
| + chrome.test.assertEq("", adview.getAttribute("ad-network")); |
| + console.log("test3 succeeded."); |
| + chrome.test.succeed(); |
| + }, 0); |
| + }, 0); |
| +} |
| + |
| +runTest1(); |
| + |
| +window.addEventListener('DOMContentLoaded', function() { |
| + runTest2(); |
| + runTest3(); |
| +}); |