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

Unified Diff: chrome/test/data/extensions/platform_apps/browser_tag_src_attribute/main.js

Issue 11111020: <browser>: Always read <browser>.src attribute from <object>.src. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments from creis@ Created 8 years, 2 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/browser_tag_src_attribute/main.js
diff --git a/chrome/test/data/extensions/platform_apps/browser_tag_src_attribute/main.js b/chrome/test/data/extensions/platform_apps/browser_tag_src_attribute/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..26342da6551c7b13c56066b892cf22c28ff1ecbe
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/browser_tag_src_attribute/main.js
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 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 checkSrc = function(element, expectedValue) {
+ // Note that element.getAttribute('src') should not be used, it can be out of
+ // sync with element.src.
+ chrome.test.assertEq(expectedValue, element.src);
+};
+
+onload = function() {
+ chrome.test.runTests([
+ function browserTag() {
+ var expectedSrcOne = 'data:text/html,<body>One</body>';
+ var expectedSrcTwo = 'data:text/html,<body>Two</body>';
+ var expectedSrcThree = 'data:text/html,<body>Three</body>';
+
+ // For setting src, we check if both browserTag.setAttribute('src', ?);
+ // and browserTag.src = ?; works propertly.
+ var browserTag = document.querySelector('browser');
+
+ // Check if initial src is set correctly.
+ checkSrc(browserTag, expectedSrcOne);
+
+ // Change the src.
+ browserTag.setAttribute('src', expectedSrcTwo);
+
+ // Timeout is necessary to give the mutation observers a chance to fire.
+ setTimeout(function() {
+ // Expect the src change to be reflected.
+ checkSrc(browserTag, expectedSrcTwo);
+ // Set src attribute directly on the element.
+ browserTag.src = expectedSrcThree;
+ setTimeout(function() {
+ // Expect the src change to be reflected.
+ checkSrc(browserTag, expectedSrcThree);
+ // Set empty src, this will be ignored.
+ browserTag.setAttribute('src', '');
+
+ setTimeout(function() {
+ // Expect empty src to be ignored.
+ checkSrc(browserTag, expectedSrcThree);
+ // Set empty src again, directly changing the src attribute.
+ browserTag.src = '';
+
+ setTimeout(function() {
+ // Expect empty src to be ignored.
+ checkSrc(browserTag, expectedSrcThree);
+ chrome.test.succeed();
+ }, 0);
+ }, 0);
+ }, 0);
+ }, 0);
+ }
+ ]);
+};

Powered by Google App Engine
This is Rietveld 408576698