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..ff47a74c4cb6128a3a3ec701d2f59a5161400599 |
--- /dev/null |
+++ b/chrome/test/data/extensions/platform_apps/ad_view/invalid_ad_network/chrometest.js |
@@ -0,0 +1,81 @@ |
+// 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. |
+ |
+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() { |
+ // Arrange |
+ var adview = document.getElementById(adview1); |
+ |
+ // Act |
+ adview.setAttribute("ad-network", "invalidAdNetwork"); |
+ |
+ // Assert |
+ // 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")); |
+ }, 0); |
+} |
+ |
+/** |
+ * Verify setting invalid ad-network value is ignored at "document load" time. |
+ */ |
+function runTest2() { |
+ // Arrange |
+ var adview = document.createElement("adview"); |
+ adview.id = adview2; |
+ document.body.appendChild(adview); |
+ |
+ // Act |
+ adview.setAttribute("ad-network", "invalidAdNetwork2"); |
+ |
+ // Assert |
+ // 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")); |
+ }, 0); |
+} |
+ |
+/** |
+ * Verify setting invalid ad-network value is ignored even after document |
+ * is fully loaded. |
+ */ |
+function runTest3() { |
+ setTimeout(function() { |
+ // Arrange |
+ var adview = document.createElement("adview"); |
+ adview.id = adview3; |
+ document.body.appendChild(adview); |
+ |
+ // Act |
+ adview.setAttribute("ad-network", "invalidAdNetwork3"); |
+ |
+ // Assert |
+ // 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")); |
+ chrome.test.sendMessage("test-finished"); |
+ }, 0); |
+ }, 0); |
+} |
+ |
+runTest1(); |
+ |
+window.addEventListener('DOMContentLoaded', function() { |
+ runTest2(); |
+ runTest3(); |
+}); |