Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1157)

Unified Diff: chrome/test/data/extensions/platform_apps/ad_view/change_ad_network/chrometest.js

Issue 12967016: Improve <adview> implementation and add tests. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Code review feedback. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/platform_apps/ad_view/change_ad_network/chrometest.js
diff --git a/chrome/test/data/extensions/platform_apps/ad_view/change_ad_network/chrometest.js b/chrome/test/data/extensions/platform_apps/ad_view/change_ad_network/chrometest.js
new file mode 100644
index 0000000000000000000000000000000000000000..4e324e68911b4a7580862d6579f4b3b53ed6fdec
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/ad_view/change_ad_network/chrometest.js
@@ -0,0 +1,62 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
benwells 2013/04/02 00:49:45 Nit: No (c) in new copyright notices.
rpaquay 2013/04/02 16:44:47 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This test checks that 1) it is possible change the value of the "ad-network"
+// attribute of an <adview> element and 2) changing the value will reset the
+// "src" attribute.
+
+function onLoadCommit(adview, guestURL) {
+ console.log("onLoadCommit(" + adview.getAttribute('ad-network') + ")");
+ // First callback: assert and run another callback
+ if (adview.getAttribute('ad-network') == 'test') {
+ // Check 'src' and 'ad-network' attributes/properties
+ chrome.test.assertEq('test', adview.getAttribute('ad-network'));
+ chrome.test.assertEq('test', adview['ad-network']);
benwells 2013/04/02 00:49:45 why do you check this twice? Or even at all, this
rpaquay 2013/04/02 16:44:47 adview is the shadow element implemented in "ad_vi
+ chrome.test.assertEq(guestURL, adview.getAttribute('src'));
+ chrome.test.assertEq(guestURL, adview.src);
benwells 2013/04/02 00:49:45 Again, why test this twice in different ways?
rpaquay 2013/04/02 16:44:47 See comment above: property and attributes are dif
+
+ adview['ad-network'] = '';
+ setTimeout(function() {
benwells 2013/04/02 00:49:45 Is there a different way to catch this without usi
rpaquay 2013/04/02 16:44:47 Not that I know of. I put a comment in other test
benwells 2013/04/03 02:49:48 Oops forgot this one. I think this should be cove
rpaquay 2013/04/03 18:30:05 I am not sure I understand what you mean.
benwells 2013/04/04 04:33:52 I mean a user of this API might want to do the sam
rpaquay 2013/04/05 16:12:08 Hmm... setAttribute is a DOM pre-defined method. I
+ // Check 'src' and 'ad-network' attributes/properties
+ chrome.test.assertEq('', adview.getAttribute('ad-network'));
+ chrome.test.assertEq('', adview['ad-network']);
+ chrome.test.assertEq('', adview.getAttribute('src'));
+ chrome.test.assertEq('', adview.src);
+
+ adview['ad-network'] = 'test2';
+ }, 0);
+ }
+ // Second callback: assert and finish test
benwells 2013/04/02 00:49:45 What triggers the second callback?
rpaquay 2013/04/02 16:44:47 The line above: adview['ad-network'] = 'test2';
benwells 2013/04/03 02:40:03 Nit: please add a comment explaining. People will
rpaquay 2013/04/03 18:30:05 Done.
+ else if (adview.getAttribute('ad-network') == 'test2') {
+ // Check 'src' and 'ad-network' attributes/properties
+ chrome.test.assertEq('test2', adview.getAttribute('ad-network'));
+ chrome.test.assertEq('test2', adview['ad-network']);
+ chrome.test.assertEq('', adview.getAttribute('src'));
+ chrome.test.assertEq('', adview['src']);
+
+ console.log("Test finished correctly.");
benwells 2013/04/02 00:49:45 Running tests through the chrome.test system makes
rpaquay 2013/04/02 16:44:47 Yes. As far as I could tell, tests run until "chro
+ chrome.test.succeed();
+ }
+};
+
+function runTests(guestURL) {
+ chrome.test.runTests([
+ function test() {
+ var adview = document.getElementsByTagName("adview")[0];
+
+ adview.addEventListener("loadcommit", function(event) {
+ onLoadCommit(adview, guestURL);
+ });
+ adview.setAttribute("src", guestURL);
+ }
+ ]);
+}
+
+window.onload = function() {
+ chrome.test.getConfig(function(config) {
+ var guestURL = 'http://localhost:' + config.testServer.port +
+ '/files/extensions/platform_apps/ad_view/ad_network_site/testsdk.html';
+ runTests(guestURL);
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698