summaryrefslogtreecommitdiffstats
path: root/dom/browser-element/mochitest/browserElement_DataURI.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/browser-element/mochitest/browserElement_DataURI.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/browser-element/mochitest/browserElement_DataURI.js')
-rw-r--r--dom/browser-element/mochitest/browserElement_DataURI.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/browserElement_DataURI.js b/dom/browser-element/mochitest/browserElement_DataURI.js
new file mode 100644
index 000000000..f57f4566a
--- /dev/null
+++ b/dom/browser-element/mochitest/browserElement_DataURI.js
@@ -0,0 +1,68 @@
+/* Any copyright is dedicated to the public domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Test that data: URIs work with mozbrowserlocationchange events.
+
+"use strict";
+SimpleTest.waitForExplicitFinish();
+browserElementTestHelpers.setEnabledPref(true);
+browserElementTestHelpers.addPermission();
+
+function runTest() {
+ var iframe1 = document.createElement('iframe');
+ iframe1.setAttribute('mozbrowser', 'true');
+ iframe1.id = 'iframe1';
+ iframe1.addEventListener('mozbrowserloadend', function if1_loadend() {
+ iframe1.removeEventListener('mozbrowserloadend', if1_loadend);
+ ok(true, 'Got first loadend event.');
+ SimpleTest.executeSoon(runTest2);
+ });
+ iframe1.src = browserElementTestHelpers.emptyPage1;
+ document.body.appendChild(iframe1);
+
+ var iframe2 = document.createElement('iframe');
+ iframe2.id = 'iframe2';
+ document.body.appendChild(iframe2);
+}
+
+function runTest2() {
+ var iframe1 = document.getElementById('iframe1');
+ var iframe2 = document.getElementById('iframe2');
+
+ var sawLoadEnd = false;
+ var sawLocationChange = false;
+
+ iframe1.addEventListener('mozbrowserlocationchange', function(e) {
+ ok(e.isTrusted, 'Event should be trusted.');
+ ok(!sawLocationChange, 'Just one locationchange event.');
+ ok(!sawLoadEnd, 'locationchange before load.');
+ is(e.detail.url, 'data:text/html,1', "event's reported location");
+ sawLocationChange = true;
+ });
+
+ iframe1.addEventListener('mozbrowserloadend', function() {
+ ok(sawLocationChange, 'Loadend after locationchange.');
+ ok(!sawLoadEnd, 'Just one loadend event.');
+ sawLoadEnd = true;
+ });
+
+ function iframe2Load() {
+ if (!sawLoadEnd || !sawLocationChange) {
+ // Spin if iframe1 hasn't loaded yet.
+ SimpleTest.executeSoon(iframe2Load);
+ return;
+ }
+ ok(true, 'Got iframe2 load.');
+ SimpleTest.finish();
+ }
+ iframe2.addEventListener('load', iframe2Load);
+
+
+ iframe1.src = 'data:text/html,1';
+
+ // Load something into iframe2 to check that it doesn't trigger a
+ // locationchange for our iframe1 listener.
+ iframe2.src = browserElementTestHelpers.emptyPage2;
+}
+
+addEventListener('testready', runTest);