incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [6/6] spec commit: Add autotest for data uris in iframes and images.
Date Tue, 18 Sep 2012 14:38:23 GMT
Add autotest for data uris in iframes and images.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/28e3d0a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/28e3d0a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/28e3d0a4

Branch: refs/heads/master
Commit: 28e3d0a45f144e1edabf525437f0488da5175495
Parents: be20d0b
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Sep 6 18:44:22 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Tue Sep 18 09:57:55 2012 -0400

----------------------------------------------------------------------
 autotest/index.html             |    1 +
 autotest/pages/all.html         |    1 +
 autotest/pages/datauri.html     |   49 ++++++++++++++++++++++++++++++++++
 autotest/tests/datauri.tests.js |   36 +++++++++++++++++++++++++
 4 files changed, 87 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/28e3d0a4/autotest/index.html
----------------------------------------------------------------------
diff --git a/autotest/index.html b/autotest/index.html
index 4dfeeb7..2260b4f 100644
--- a/autotest/index.html
+++ b/autotest/index.html
@@ -40,6 +40,7 @@
     <a href="pages/capture.html" class="btn large" style="width:100%;">Run Capture
Tests</a>
     <a href="pages/compass.html" class="btn large" style="width:100%;">Run Compass
Tests</a>
     <a href="pages/contacts.html" class="btn large" style="width:100%;">Run Contacts
Tests</a>
+    <a href="pages/datauri.html" class="btn large" style="width:100%;">Run Data URI
Tests</a>
     <a href="pages/device.html" class="btn large" style="width:100%;">Run Device Tests</a>
     <a href="pages/file.html" class="btn large" style="width:100%;">Run File Tests</a>
     <a href="pages/filetransfer.html" class="btn large" style="width:100%;">Run FileTransfer
Tests</a>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/28e3d0a4/autotest/pages/all.html
----------------------------------------------------------------------
diff --git a/autotest/pages/all.html b/autotest/pages/all.html
index 4c283c2..d9aa98f 100644
--- a/autotest/pages/all.html
+++ b/autotest/pages/all.html
@@ -49,6 +49,7 @@
   <script type="text/javascript" src="../tests/compass.tests.js"></script>
   <script type="text/javascript" src="../tests/contacts.tests.js"></script>
   <script type="text/javascript" src="../tests/camera.tests.js"></script>
+  <script type="text/javascript" src="../tests/datauri.tests.js"></script>
   <script type="text/javascript" src="../tests/device.tests.js"></script>
   <script type="text/javascript" src="../tests/file.tests.js"></script>
   <script type="text/javascript" src="../tests/filetransfer.tests.js"></script>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/28e3d0a4/autotest/pages/datauri.html
----------------------------------------------------------------------
diff --git a/autotest/pages/datauri.html b/autotest/pages/datauri.html
new file mode 100644
index 0000000..41e0151
--- /dev/null
+++ b/autotest/pages/datauri.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <title>Cordova: Data URI tests</title>
+
+  <meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes,
initial-scale=1.0;" />
+  <!-- Load jasmine -->
+  <link href="../jasmine.css" rel="stylesheet"/>
+  <script type="text/javascript" src="../jasmine.js"></script>
+  <script type="text/javascript" src="../html/HtmlReporterHelpers.js"></script>
+  <script type="text/javascript" src="../html/HtmlReporter.js"></script>
+  <script type="text/javascript" src="../html/ReporterView.js"></script>
+  <script type="text/javascript" src="../html/SpecView.js"></script>
+  <script type="text/javascript" src="../html/SuiteView.js"></script>
+  <script type="text/javascript" src="../html/TrivialReporter.js"></script>
+
+  <!-- Source -->
+  <script type="text/javascript" src="../../cordova.js"></script>
+
+  <!-- Load Test Runner -->
+  <script type="text/javascript" src="../test-runner.js"></script>
+
+  <!-- Tests -->
+  <script type="text/javascript" src="../tests/datauri.tests.js"></script>
+
+  <script type="text/javascript">
+    document.addEventListener('deviceready', function () {
+      var jasmineEnv = jasmine.getEnv();
+      jasmineEnv.updateInterval = 1000;
+
+      var htmlReporter = new jasmine.HtmlReporter();
+
+      jasmineEnv.addReporter(htmlReporter);
+
+      jasmineEnv.specFilter = function(spec) {
+        return htmlReporter.specFilter(spec);
+      };
+
+      jasmineEnv.execute();
+    }, false);
+  </script>
+</head>
+
+<body>
+  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+</body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/28e3d0a4/autotest/tests/datauri.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/datauri.tests.js b/autotest/tests/datauri.tests.js
new file mode 100644
index 0000000..2e54810
--- /dev/null
+++ b/autotest/tests/datauri.tests.js
@@ -0,0 +1,36 @@
+describe('data uris', function () {
+    it("should work with iframes", function() {
+        var gotFoo = false,
+            frame = document.createElement('iframe');
+        function onMessage(msg) {
+            gotFoo = gotFoo || msg.data == 'foo';
+        };
+
+        this.after(function() {
+            document.body.removeChild(frame);
+            window.removeEventListener('message', onMessage, false);
+        });
+
+        window.addEventListener('message', onMessage, false);
+        frame.src = 'data:text/html;charset=utf-8,%3Chtml%3E%3Cscript%3Eparent.postMessage%28%27foo%27%2C%27%2A%27%29%3C%2Fscript%3E%3C%2Fhtml%3E'
+        document.body.appendChild(frame);
+        waitsFor(function() {
+            return gotFoo;
+        }, 'iframe did not load.', 1000);
+        runs(function() {
+            expect(gotFoo).toBe(true);
+        });
+    });
+    it("should work with images", function() {
+        var img = new Image();
+        img.onload = jasmine.createSpy('onLoad');
+        img.onerror = jasmine.createSpy('onError');
+        img.src = 'data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7'
+        waitsFor(function() {
+            return img.onload.wasCalled || img.onerror.wasCalled;
+        }, 'image did not load or error', 1000);
+        runs(function() {
+            expect(img.onload).toHaveBeenCalled();
+        });
+    });
+});


Mime
View raw message