summaryrefslogtreecommitdiff
path: root/embedding/test
diff options
context:
space:
mode:
Diffstat (limited to 'embedding/test')
-rw-r--r--embedding/test/320x240.ogvbin0 -> 28942 bytes
-rw-r--r--embedding/test/browser.ini6
-rw-r--r--embedding/test/browser_bug1204626.js87
-rw-r--r--embedding/test/bug1170334_iframe.xml3
-rw-r--r--embedding/test/bug1170334_style.css1
-rw-r--r--embedding/test/bug1204626_doc0.html3
-rw-r--r--embedding/test/bug1204626_doc1.html5
-rw-r--r--embedding/test/bug293834_form.html26
-rw-r--r--embedding/test/bug449141_page.html12
-rw-r--r--embedding/test/chrome.ini11
-rw-r--r--embedding/test/mochitest.ini14
-rw-r--r--embedding/test/moz.build9
-rw-r--r--embedding/test/test_bug1170334_wbp_xmlstyle.html80
-rw-r--r--embedding/test/test_bug1192654.html78
-rw-r--r--embedding/test/test_bug293834.html137
-rw-r--r--embedding/test/test_bug449141.html102
-rw-r--r--embedding/test/test_bug499115.html66
-rw-r--r--embedding/test/test_nsFind.html241
-rw-r--r--embedding/test/test_private_window_from_content.html12
-rw-r--r--embedding/test/test_window_open_position_constraint.html56
-rw-r--r--embedding/test/test_window_open_units.html37
21 files changed, 986 insertions, 0 deletions
diff --git a/embedding/test/320x240.ogv b/embedding/test/320x240.ogv
new file mode 100644
index 0000000000..093158432a
--- /dev/null
+++ b/embedding/test/320x240.ogv
Binary files differ
diff --git a/embedding/test/browser.ini b/embedding/test/browser.ini
new file mode 100644
index 0000000000..936b071049
--- /dev/null
+++ b/embedding/test/browser.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+support-files =
+ bug1204626_doc0.html
+ bug1204626_doc1.html
+
+[browser_bug1204626.js]
diff --git a/embedding/test/browser_bug1204626.js b/embedding/test/browser_bug1204626.js
new file mode 100644
index 0000000000..165cb9b43a
--- /dev/null
+++ b/embedding/test/browser_bug1204626.js
@@ -0,0 +1,87 @@
+"use strict"; // -*- js-indent-level: 2; indent-tabs-mode: nil -*-
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+const contentBase = "https://example.com/browser/embedding/test/";
+const chromeBase = "chrome://mochitests/content/browser/embedding/test/";
+const testPageURL = contentBase + "bug1204626_doc0.html";
+
+function one_test(delay, continuation) {
+ let delayStr = delay === null ? "no delay" : "delay = " + delay + "ms";
+ let browser;
+
+ BrowserTestUtils.openNewForegroundTab(gBrowser, testPageURL).then((tab) => {
+ browser = tab.linkedBrowser;
+ let persistable = browser.QueryInterface(Ci.nsIFrameLoaderOwner)
+ .frameLoader
+ .QueryInterface(Ci.nsIWebBrowserPersistable);
+ persistable.startPersistence(/* outer window ID: */ 0, {
+ onDocumentReady,
+ onError: function(status) {
+ ok(false, new Components.Exception("startPersistence failed", status));
+ continuation();
+ }
+ });
+ });
+
+ function onDocumentReady(doc) {
+ const nameStem="test_bug1204626_" + Date.now();
+ let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Ci.nsIWebBrowserPersist);
+ let tmp = Cc["@mozilla.org/file/directory_service;1"]
+ .getService(Ci.nsIProperties)
+ .get("TmpD", Ci.nsIFile);
+ let tmpFile = tmp.clone();
+ tmpFile.append(nameStem + "_saved.html");
+ let tmpDir = tmp.clone();
+ tmpDir.append(nameStem + "_files");
+
+ registerCleanupFunction(function cleanUp() {
+ if (tmpFile.exists()) {
+ tmpFile.remove(/* recursive: */ false);
+ }
+ if (tmpDir.exists()) {
+ tmpDir.remove(/* recursive: */ true);
+ }
+ });
+
+ wbp.progressListener = {
+ onProgressChange: function(){},
+ onLocationChange: function(){},
+ onStatusChange: function(){},
+ onSecurityChange: function(){},
+ onStateChange: function wbp_stateChange(_wbp, _req, state, _status) {
+ if ((state & Ci.nsIWebProgressListener.STATE_STOP) == 0) {
+ return;
+ }
+ ok(true, "Finished save (" + delayStr + ") but might have crashed.");
+ continuation();
+ }
+ }
+
+ function doSave() {
+ wbp.saveDocument(doc, tmpFile, tmpDir, null, 0, 0);
+ }
+ if (delay === null) {
+ doSave();
+ } else {
+ setTimeout(doSave, delay);
+ }
+ browser.messageManager.loadFrameScript("data:,content.window.close()", true);
+ }
+}
+
+function test() {
+ waitForExplicitFinish();
+ // 0ms breaks having the actor under PBrowser, but not 10ms.
+ // 10ms provokes the double-__delete__, but not 0ms.
+ // And a few others, just in case.
+ const testRuns = [null, 0, 10, 0, 10, 20, 50, 100];
+ let i = 0;
+ (function next_test() {
+ if (i < testRuns.length) {
+ one_test(testRuns[i++], next_test);
+ } else {
+ finish();
+ }
+ })();
+}
diff --git a/embedding/test/bug1170334_iframe.xml b/embedding/test/bug1170334_iframe.xml
new file mode 100644
index 0000000000..1821e07f96
--- /dev/null
+++ b/embedding/test/bug1170334_iframe.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet href="bug1170334_style.css" type="text/css" title="&quot;?&gt;FAIL"?>
+<thing/>
diff --git a/embedding/test/bug1170334_style.css b/embedding/test/bug1170334_style.css
new file mode 100644
index 0000000000..476c22b695
--- /dev/null
+++ b/embedding/test/bug1170334_style.css
@@ -0,0 +1 @@
+/* This stylesheet intentionally left blank. */
diff --git a/embedding/test/bug1204626_doc0.html b/embedding/test/bug1204626_doc0.html
new file mode 100644
index 0000000000..cbced762c3
--- /dev/null
+++ b/embedding/test/bug1204626_doc0.html
@@ -0,0 +1,3 @@
+<!DOCTYPE html>
+<p>This is a document, and it contains an iframe:</p>
+<iframe src="bug1204626_doc1.html"></iframe>
diff --git a/embedding/test/bug1204626_doc1.html b/embedding/test/bug1204626_doc1.html
new file mode 100644
index 0000000000..cffc283d2c
--- /dev/null
+++ b/embedding/test/bug1204626_doc1.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<p>This is the document inside the iframe. <small>(Currently this
+document doesn't even need to exist in order to reproduce the bug in
+question, as long as the parent contains a frame, but it's probably
+best not to depend on that.)</small></p>
diff --git a/embedding/test/bug293834_form.html b/embedding/test/bug293834_form.html
new file mode 100644
index 0000000000..6ad19f02f5
--- /dev/null
+++ b/embedding/test/bug293834_form.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>Nested iframe for bug 293834</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ </head>
+ <body>
+ <form>
+ not prefilled: <input id="a-text" type="text"></input><br>
+ prefilled: <input id="a-prefilled-text" type="text" value="prefill "></input><br>
+
+ <input name="a-radio" id="radioa" value="radio-a" type="radio">Should be saved checked</input><br>
+ <input name="a-radio" value="radio-c" type="radio" checked="true">Initially checked</input><br>
+ <select id="aselect">
+ <option value="target">Should be saved selected</option>
+ <option value="default" selected="selected">Default Selected</option>
+ </select><br>
+ not prefilled: <textarea id="a-textbox"></textarea><br>
+ prefilled: <textarea id="a-prefilled-textbox">prefill </textarea><br>
+ <input id="a-checkbox" type="checkbox">Should be saved checked</input><br>
+ <input id="a-prefilled-checkbox" type="checkbox" checked="true">Initiallly checked</input><br>
+ </form>
+ </body>
+</html>
+
diff --git a/embedding/test/bug449141_page.html b/embedding/test/bug449141_page.html
new file mode 100644
index 0000000000..586b955056
--- /dev/null
+++ b/embedding/test/bug449141_page.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>Nested iframe for bug 449141</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ </head>
+ <body>
+ <video src='320x240.ogv'></video>
+ </body>
+</html>
+
diff --git a/embedding/test/chrome.ini b/embedding/test/chrome.ini
new file mode 100644
index 0000000000..9954dde591
--- /dev/null
+++ b/embedding/test/chrome.ini
@@ -0,0 +1,11 @@
+[DEFAULT]
+support-files =
+ 320x240.ogv
+ bug449141_page.html
+ bug1170334_iframe.xml
+ bug1170334_style.css
+
+[test_bug449141.html]
+skip-if = toolkit == 'android'
+[test_bug1170334_wbp_xmlstyle.html]
+[test_bug1192654.html]
diff --git a/embedding/test/mochitest.ini b/embedding/test/mochitest.ini
new file mode 100644
index 0000000000..79705d2d70
--- /dev/null
+++ b/embedding/test/mochitest.ini
@@ -0,0 +1,14 @@
+[DEFAULT]
+support-files =
+ bug293834_form.html
+
+[test_bug293834.html]
+skip-if = (toolkit == "cocoa" && e10s) # bug 1252223
+[test_bug499115.html]
+[test_nsFind.html]
+[test_private_window_from_content.html]
+# Next two tests are disabled in e10s because of bug 989501.
+[test_window_open_position_constraint.html]
+skip-if = toolkit == 'android'
+[test_window_open_units.html]
+skip-if = toolkit == 'android'
diff --git a/embedding/test/moz.build b/embedding/test/moz.build
new file mode 100644
index 0000000000..1ec8488c98
--- /dev/null
+++ b/embedding/test/moz.build
@@ -0,0 +1,9 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+MOCHITEST_MANIFESTS += ['mochitest.ini']
+MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
+BROWSER_CHROME_MANIFESTS += ['browser.ini']
diff --git a/embedding/test/test_bug1170334_wbp_xmlstyle.html b/embedding/test/test_bug1170334_wbp_xmlstyle.html
new file mode 100644
index 0000000000..4dee9a6ba7
--- /dev/null
+++ b/embedding/test/test_bug1170334_wbp_xmlstyle.html
@@ -0,0 +1,80 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1170334
+-->
+<head>
+ <title>Test for Bug 1170334 (nsWebBrowserPersist vs. XML stylesheets)</title>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1170334">Mozilla Bug 1170334</a>
+<p id="display"></p>
+<pre id="results"></pre>
+<div id="content">
+ <iframe src="bug1170334_iframe.xml" id="iframe"></iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript;version=1.7">
+const nameStem="test_bug1170334_" + Date.now();
+const { Ci, Cc, Cu, Cr } = SpecialPowers;
+let iframe = document.getElementById("iframe");
+
+SimpleTest.waitForExplicitFinish();
+
+iframe.onload = function iframe_onload1() {
+ let doc = iframe.contentDocument;
+ ok(doc, "iframe content document exists");
+
+ let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Ci.nsIWebBrowserPersist);
+ let ios = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+ let tmp = Cc["@mozilla.org/file/directory_service;1"]
+ .getService(Ci.nsIProperties)
+ .get("TmpD", Ci.nsIFile);
+ let tmpFile = tmp.clone();
+ tmpFile.append(nameStem + "_iframe.xml");
+ let tmpDir = tmp.clone();
+ tmpDir.append(nameStem + "_files");
+
+ // When the document in the iframe is saved, try to load the result.
+ wbp.progressListener = {
+ onProgressChange: function(){},
+ onLocationChange: function(){},
+ onStatusChange: function(){},
+ onSecurityChange: function(){},
+ onStateChange: function wbp_stateChange(_wbp, _req, state, status) {
+ if ((state & Ci.nsIWebProgressListener.STATE_STOP) == 0) {
+ return;
+ }
+ is(status, Cr.NS_OK, "nsWebBrowserPersist status");
+ iframe.onload = function iframe_onload2() {
+ let elem = iframe.contentDocument.documentElement;
+ is(elem && elem.tagName, "thing", "document element tag");
+ if (elem && elem.tagName == "parsererror") {
+ ok(false, "Parser error: " + elem.textContent);
+ }
+
+ cleanUp();
+ SimpleTest.finish();
+ };
+ iframe.src = ios.newFileURI(tmpFile).spec;
+ }
+ };
+ wbp.saveDocument(doc, tmpFile, tmpDir, null, 0, 0);
+
+ function cleanUp() {
+ if (tmpFile.exists()) {
+ tmpFile.remove(/* recursive: */ false);
+ }
+ if (tmpDir.exists()) {
+ tmpDir.remove(/* recursive: */ true);
+ }
+ }
+};
+</script>
+</pre>
+</body>
+</html>
diff --git a/embedding/test/test_bug1192654.html b/embedding/test/test_bug1192654.html
new file mode 100644
index 0000000000..f7e97f6a68
--- /dev/null
+++ b/embedding/test/test_bug1192654.html
@@ -0,0 +1,78 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1192654
+-->
+<head>
+ <title>Test for Bug 1192654 (nsWebBrowser vs. nonpersistable subdocuments)</title>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1192654">Mozilla Bug 1192654</a>
+<p id="display"></p>
+<pre id="results"></pre>
+<div id="content">
+ <!-- The outer iframe uses a data URI for simplicity; this would
+ also work if it were loaded from a support file by relative
+ URI. The inner iframe (the one nsWebBrowserPersist traverses)
+ uses a data URI because data: is a non-persistable scheme and
+ thus triggers the bug.
+ -->
+ <iframe src="data:text/html,<iframe%20src=%22data:text/plain,Example%22>"
+ id="iframe"></iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript;version=1.7">
+const nameStem="test_bug1192654_" + Date.now();
+const { Ci, Cc, Cu, Cr } = SpecialPowers;
+let iframe = document.getElementById("iframe");
+
+SimpleTest.waitForExplicitFinish();
+
+iframe.onload = function iframe_onload1() {
+ let doc = iframe.contentDocument;
+ ok(doc, "iframe content document exists");
+
+ let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Ci.nsIWebBrowserPersist);
+ let tmp = Cc["@mozilla.org/file/directory_service;1"]
+ .getService(Ci.nsIProperties)
+ .get("TmpD", Ci.nsIFile);
+ let tmpFile = tmp.clone();
+ tmpFile.append(nameStem + "_iframe.xml");
+ let tmpDir = tmp.clone();
+ tmpDir.append(nameStem + "_files");
+
+ wbp.progressListener = {
+ onProgressChange: function(){},
+ onLocationChange: function(){},
+ onStatusChange: function(){},
+ onSecurityChange: function(){},
+ onStateChange: wbp_stateChange,
+ };
+ SimpleTest.registerCleanupFunction(cleanUp);
+
+ wbp.saveDocument(doc, tmpFile, tmpDir, null, 0, 0);
+
+ function wbp_stateChange(_wbp, _req, state, status) {
+ if ((state & Ci.nsIWebProgressListener.STATE_STOP) == 0) {
+ return;
+ }
+ is(status, Cr.NS_OK, "nsWebBrowserPersist status");
+ SimpleTest.finish();
+ }
+
+ function cleanUp() {
+ if (tmpFile.exists()) {
+ tmpFile.remove(/* recursive: */ false);
+ }
+ if (tmpDir.exists()) {
+ tmpDir.remove(/* recursive: */ true);
+ }
+ }
+};
+</script>
+</pre>
+</body>
+</html>
diff --git a/embedding/test/test_bug293834.html b/embedding/test/test_bug293834.html
new file mode 100644
index 0000000000..0747bf8b74
--- /dev/null
+++ b/embedding/test/test_bug293834.html
@@ -0,0 +1,137 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=293834
+-->
+<head>
+ <title>Test for Bug 293834</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=293834">Mozilla Bug 293834</a>
+<p id="display">
+
+</p>
+<pre id="results"></pre>
+<div id="content" style="display: none">
+ <iframe src="bug293834_form.html" id="source"></iframe>
+ <br>
+ <iframe id="dest"></iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+/** Test for Bug 293834 **/
+
+var textareas = ["a-textbox", "a-prefilled-textbox"];
+var textboxes = ["a-text", "a-prefilled-text"];
+
+function fillform(doc) {
+ for (var i in textareas) {
+ doc.getElementById(textareas[i]).textContent += "form state";
+ }
+ for (var i in textboxes) {
+ doc.getElementById(textboxes[i]).value += "form state";
+ }
+ doc.getElementById('a-checkbox').checked = true;
+ doc.getElementById("radioa").checked = true;
+ doc.getElementById("aselect").selectedIndex = 0;
+}
+
+function checkform(doc) {
+ for (var i in textareas) {
+ var textContent = doc.getElementById(textareas[i]).textContent;
+ ok(/form\s+state/m.test(textContent),
+ "Modified textarea "+textareas[i]+" form state not preserved!");
+ }
+ for (var i in textboxes) {
+ var value = doc.getElementById(textboxes[i]).value;
+ ok(/form\s+state/m.test(value),
+ "Modified textbox "+textboxes[i]+" form state not preserved!");
+ }
+ ok(doc.getElementById('a-checkbox').checked,
+ "Modified checkbox checked state not preserved!");
+ ok(doc.getElementById("radioa").checked,
+ "Modified radio checked state not preserved!");
+ ok(doc.getElementById("aselect").selectedIndex == 0,
+ "Modified select selected index not preserved");
+}
+
+const Cc = SpecialPowers.Cc;
+const Ci = SpecialPowers.Ci;
+
+function getTempDir() {
+ return Cc["@mozilla.org/file/directory_service;1"]
+ .getService(Ci.nsIProperties)
+ .get("TmpD", Ci.nsILocalFile);
+}
+
+function getFileContents(aFile) {
+ const PR_RDONLY = 0x01;
+ var fileStream = Cc["@mozilla.org/network/file-input-stream;1"]
+ .createInstance(Ci.nsIFileInputStream);
+ fileStream.init(aFile, PR_RDONLY, 0400,
+ Ci.nsIFileInputStream.DELETE_ON_CLOSE
+ | Ci.nsIFileInputStream.CLOSE_ON_EOF);
+ var inputStream = Cc["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Ci.nsIScriptableInputStream);
+ inputStream.init(fileStream);
+ var data = "";
+ do {
+ var str = inputStream.read(inputStream.available());
+ data += str;
+ } while(str.length > 0);
+
+ return data;
+}
+
+function persistDocument(aDoc) {
+ const nsIWBP = Ci.nsIWebBrowserPersist;
+ const persistFlags =
+ nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES
+ | nsIWBP.PERSIST_FLAGS_FROM_CACHE
+ | nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION
+ const encodingFlags =
+ nsIWBP.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES;
+
+ var ioService = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+
+
+ var file = getTempDir();
+ file.append("bug293834-serialized.html");
+
+ var persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Ci.nsIWebBrowserPersist);
+ persist.progressListener = null;
+ persist.persistFlags = persistFlags;
+ const kWrapColumn = 80;
+ var folder = getTempDir();
+ folder.append("bug293834-serialized");
+ persist.saveDocument(aDoc, ioService.newFileURI(file),
+ folder,
+ aDoc.contentType,
+ encodingFlags, kWrapColumn);
+ return getFileContents(file);
+}
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+ var srcDoc = document.getElementById('source').contentDocument;
+ fillform(srcDoc);
+ checkform(srcDoc);
+ var serializedString = persistDocument(srcDoc);
+
+ // We can't access file:/// URLs directly for security reasons,
+ // so we have to parse the serialized content string indirectly
+ var targetDoc = document.getElementById('dest').contentDocument;
+ targetDoc.write(serializedString);
+
+ checkform(targetDoc);
+ SimpleTest.finish();
+});
+</script>
+</pre>
+</body>
+</html>
diff --git a/embedding/test/test_bug449141.html b/embedding/test/test_bug449141.html
new file mode 100644
index 0000000000..0b75ff331c
--- /dev/null
+++ b/embedding/test/test_bug449141.html
@@ -0,0 +1,102 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=449141
+-->
+<head>
+ <title>Test for Bug 449141</title>
+ <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=449141">Mozilla Bug 449141</a>
+<p id="display">
+
+</p>
+<pre id="results"></pre>
+<div id="content" style="display: none">
+ <iframe src="bug449141_page.html" id="source"></iframe>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+/** Test for Bug 449141 **/
+
+const Cc = SpecialPowers.Cc;
+const Ci = SpecialPowers.Ci;
+
+function getTempDir() {
+ return Cc["@mozilla.org/file/directory_service;1"]
+ .getService(Ci.nsIProperties)
+ .get("TmpD", Ci.nsILocalFile);
+}
+
+// STATE_STOP from nsIWebProgressListener.idl
+const STATE_STOP = 0x00000010;
+
+var progressListener = {
+ onProgressChange: function() {
+ /* Ignore progress callback */
+ },
+ onStateChange: function(aProgress, aRequest, aStateFlag, aStatus) {
+ if (aStateFlag & STATE_STOP) {
+ var dirExists = false;
+ var videoExists = false;
+
+ var videoFile = getTempDir();
+ videoFile.append(this.dirName);
+ dirExists = videoFile.exists();
+ videoFile.append("320x240.ogv");
+ videoExists = videoFile.exists();
+ this.folder.remove(true);
+ this.file.remove(false);
+ ok(dirExists, 'Directory containing video file should be created');
+ ok(videoExists, 'Video should be persisted with document');
+ SimpleTest.finish();
+ }
+ }
+};
+
+function persistDocument(aDoc) {
+ const nsIWBP = Ci.nsIWebBrowserPersist;
+ const persistFlags =
+ nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES
+ | nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION
+ const encodingFlags =
+ nsIWBP.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES;
+
+ var ioService = Cc["@mozilla.org/network/io-service;1"]
+ .getService(Ci.nsIIOService);
+
+ var id = Math.round(Math.random() * 10000);
+ var dirName = "bug449141_serialized" + id;
+ progressListener.dirName = dirName;
+
+ var file = getTempDir();
+ file.append("bug449141-serialized" + id + ".html");
+
+ var persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Ci.nsIWebBrowserPersist);
+ persist.progressListener = progressListener;
+ persist.persistFlags = persistFlags;
+ const kWrapColumn = 80;
+ var folder = getTempDir();
+ folder.append(dirName);
+ progressListener.folder = folder;
+ progressListener.file = file;
+ persist.saveDocument(aDoc, ioService.newFileURI(file),
+ folder,
+ aDoc.contentType,
+ encodingFlags, kWrapColumn);
+}
+
+SimpleTest.waitForExplicitFinish();
+
+addLoadEvent(function() {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var srcDoc = document.getElementById('source').contentDocument;
+ persistDocument(srcDoc);
+});
+</script>
+</pre>
+</body>
+</html>
diff --git a/embedding/test/test_bug499115.html b/embedding/test/test_bug499115.html
new file mode 100644
index 0000000000..c51dc61a8e
--- /dev/null
+++ b/embedding/test/test_bug499115.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=499115
+-->
+<head>
+ <title>Test for Bug 499115</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body onload="onLoad();">
+ <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=499115">Mozilla Bug 499115</a>
+ <p id="display"></p>
+ <div id="content" style="display: none">
+ </div>
+ <pre id="test">
+ <script type="application/javascript">
+
+ /** Test for Bug 499115 **/
+ SimpleTest.waitForExplicitFinish();
+
+ const SEARCH_TEXT="minefield";
+
+ function getMatches() {
+ var numMatches = 0;
+
+ var searchRange = document.createRange();
+ searchRange.selectNodeContents(document.body);
+
+ var startPoint = searchRange.cloneRange();
+ startPoint.collapse(true);
+
+ var endPoint = searchRange.cloneRange();
+ endPoint.collapse(false);
+
+ var retRange = null;
+ var finder = SpecialPowers.Cc["@mozilla.org/embedcomp/rangefind;1"]
+ .createInstance(SpecialPowers.Ci.nsIFind);
+
+ finder.caseSensitive = false;
+
+ while ((retRange = finder.Find(SEARCH_TEXT, searchRange,
+ startPoint, endPoint))) {
+ numMatches++;
+
+ // Start next search from end of current match
+ startPoint = retRange.cloneRange();
+ startPoint.collapse(false);
+ }
+
+ return numMatches;
+ }
+
+ function onLoad() {
+ var matches = getMatches();
+ is(matches, 2, "found second match in anonymous content");
+ SimpleTest.finish();
+ }
+ </script>
+ </pre>
+<input type="text" value="minefield minefield"></body>
+</html>
diff --git a/embedding/test/test_nsFind.html b/embedding/test/test_nsFind.html
new file mode 100644
index 0000000000..5f5a4687ac
--- /dev/null
+++ b/embedding/test/test_nsFind.html
@@ -0,0 +1,241 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=450048
+-->
+<head>
+ <meta charset="UTF-8">
+ <title>Test for nsFind::Find()</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450048">Mozilla Bug 450048</a>
+<p id="display">This is the text to search i<b>n&shy;t</b>o</p>
+<p id="quotes">"straight" and &ldquo;curly&rdquo; and &lsquo;didn't&rsquo; and 'doesn&rsquo;t'</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 450048 **/
+
+ // Check nsFind class and its nsIFind interface.
+
+ var rf = SpecialPowers.Cc["@mozilla.org/embedcomp/rangefind;1"]
+ .getService(SpecialPowers.Ci.nsIFind);
+
+ var display = window.document.getElementById("display");
+ var searchRange = window.document.createRange();
+ searchRange.setStart(display, 0);
+ searchRange.setEnd(display, display.childNodes.length);
+ var startPt = searchRange;
+ var endPt = searchRange;
+
+ // Check |null| detection on |aPatText| parameter.
+ try {
+ rf.Find(null, searchRange, startPt, endPt);
+
+ ok(false, "Missing NS_ERROR_NULL_POINTER exception");
+ } catch (e) {
+ e = SpecialPowers.wrap(e);
+ if (e.result == SpecialPowers.Cr.NS_ERROR_NULL_POINTER) {
+ ok(true, null);
+ } else {
+ throw e;
+ }
+ }
+
+ // Check |null| detection on |aSearchRange| parameter.
+ try {
+ rf.Find("", null, startPt, endPt);
+
+ ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
+ } catch (e) {
+ e = SpecialPowers.wrap(e);
+ if (e.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
+ ok(true, null);
+ } else {
+ throw e;
+ }
+ }
+
+ // Check |null| detection on |aStartPoint| parameter.
+ try {
+ rf.Find("", searchRange, null, endPt);
+
+ ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
+ } catch (e) {
+ e = SpecialPowers.wrap(e);
+ if (e.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
+ ok(true, null);
+ } else {
+ throw e;
+ }
+ }
+
+ // Check |null| detection on |aEndPoint| parameter.
+ try {
+ rf.Find("", searchRange, startPt, null);
+
+ ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
+ } catch (e) {
+ e = SpecialPowers.wrap(e);
+ if (e.result == SpecialPowers.Cr.NS_ERROR_ILLEGAL_VALUE) {
+ ok(true, null);
+ } else {
+ throw e;
+ }
+ }
+
+ var searchValue, retRange;
+
+ rf.findBackwards = false;
+
+ rf.caseSensitive = false;
+
+ searchValue = "TexT";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(retRange, "\"" + searchValue + "\" not found (not caseSensitive)");
+
+ rf.caseSensitive = true;
+
+ // searchValue = "TexT";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(!retRange, "\"" + searchValue + "\" found (caseSensitive)");
+
+ searchValue = "text";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(retRange, "\"" + searchValue + "\" not found");
+
+ // Matches |i<b>n&shy;t</b>o|.
+ searchValue = "into";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(retRange, "\"" + searchValue + "\" not found");
+
+ // Matches inside |search|.
+ searchValue = "ear";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(retRange, "\"" + searchValue + "\" not found");
+
+ // Set new start point (to end of last search).
+ startPt = retRange.endContainer.ownerDocument.createRange();
+ startPt.setStart(retRange.endContainer, retRange.endOffset);
+ startPt.setEnd(retRange.endContainer, retRange.endOffset);
+
+ searchValue = "t";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(retRange, "\"" + searchValue + "\" not found (forward)");
+
+ searchValue = "the";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(!retRange, "\"" + searchValue + "\" found (forward)");
+
+ rf.findBackwards = true;
+
+ // searchValue = "the";
+ retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+ ok(retRange, "\"" + searchValue + "\" not found (backward)");
+
+
+ // Curly quotes and straight quotes should match.
+
+ rf.caseSensitive = false;
+ rf.findBackwards = false;
+
+ function find(node, searchValue) {
+ var range = document.createRange();
+ range.setStart(node, 0);
+ range.setEnd(node, node.childNodes.length);
+ return rf.Find(searchValue, range, range, range);
+ }
+
+ function assertFound(node, searchValue) {
+ ok(find(node, searchValue), "\"" + searchValue + "\" not found");
+ }
+
+ function assertNotFound(node, searchValue) {
+ ok(!find(node, searchValue), "\"" + searchValue + "\" found");
+ }
+
+ var quotes = document.getElementById("quotes");
+
+ assertFound(quotes, "\"straight\"");
+ assertFound(quotes, "\u201Cstraight\u201D");
+
+ assertNotFound(quotes, "'straight'");
+ assertNotFound(quotes, "\u2018straight\u2019");
+ assertNotFound(quotes, "\u2019straight\u2018");
+ assertNotFound(quotes, ".straight.");
+
+ assertFound(quotes, "\"curly\"");
+ assertFound(quotes, "\u201Ccurly\u201D");
+
+ assertNotFound(quotes, "'curly'");
+ assertNotFound(quotes, "\u2018curly\u2019");
+ assertNotFound(quotes, ".curly.");
+
+ assertFound(quotes, "didn't");
+ assertFound(quotes, "didn\u2018t");
+ assertFound(quotes, "didn\u2019t");
+
+ assertNotFound(quotes, "didnt");
+ assertNotFound(quotes, "didn t");
+ assertNotFound(quotes, "didn.t");
+
+ assertFound(quotes, "'didn't'");
+ assertFound(quotes, "'didn\u2018t'");
+ assertFound(quotes, "'didn\u2019t'");
+ assertFound(quotes, "\u2018didn't\u2019");
+ assertFound(quotes, "\u2019didn't\u2018");
+ assertFound(quotes, "\u2018didn't\u2018");
+ assertFound(quotes, "\u2019didn't\u2019");
+ assertFound(quotes, "\u2018didn\u2019t\u2019");
+ assertFound(quotes, "\u2019didn\u2018t\u2019");
+ assertFound(quotes, "\u2018didn\u2019t\u2018");
+
+ assertNotFound(quotes, "\"didn't\"");
+ assertNotFound(quotes, "\u201Cdidn't\u201D");
+
+ assertFound(quotes, "doesn't");
+ assertFound(quotes, "doesn\u2018t");
+ assertFound(quotes, "doesn\u2019t");
+
+ assertNotFound(quotes, "doesnt");
+ assertNotFound(quotes, "doesn t");
+ assertNotFound(quotes, "doesn.t");
+
+ assertFound(quotes, "'doesn't'");
+ assertFound(quotes, "'doesn\u2018t'");
+ assertFound(quotes, "'doesn\u2019t'");
+ assertFound(quotes, "\u2018doesn't\u2019");
+ assertFound(quotes, "\u2019doesn't\u2018");
+ assertFound(quotes, "\u2018doesn't\u2018");
+ assertFound(quotes, "\u2019doesn't\u2019");
+ assertFound(quotes, "\u2018doesn\u2019t\u2019");
+ assertFound(quotes, "\u2019doesn\u2018t\u2019");
+ assertFound(quotes, "\u2018doesn\u2019t\u2018");
+
+ assertNotFound(quotes, "\"doesn't\"");
+ assertNotFound(quotes, "\u201Cdoesn't\u201D");
+
+ // Curly quotes and straight quotes should not match.
+ rf.caseSensitive = true;
+
+ assertFound(quotes, "\"straight\"");
+ assertNotFound(quotes, "\u201Cstraight\u201D");
+
+ assertNotFound(quotes, "\"curly\"");
+ assertFound(quotes, "\u201Ccurly\u201D");
+
+ assertFound(quotes, "\u2018didn't\u2019");
+ assertNotFound(quotes, "'didn't'");
+
+ assertFound(quotes, "'doesn\u2019t'");
+ assertNotFound(quotes, "'doesn\u2018t'");
+ assertNotFound(quotes, "'doesn't'");
+</script>
+</pre>
+</body>
+</html>
diff --git a/embedding/test/test_private_window_from_content.html b/embedding/test/test_private_window_from_content.html
new file mode 100644
index 0000000000..4b64fb232e
--- /dev/null
+++ b/embedding/test/test_private_window_from_content.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<script>
+ // Make sure that we cannot open private browsing windows from unprivileged content
+ var win = window.open("about:blank", "_blank", "private");
+ ok(!SpecialPowers.isContentWindowPrivate(win));
+ win.close();
+ // Also, make sure that passing non-private doesn't make any difference either
+ win = window.open("about:blank", "_blank", "non-private");
+ ok(!SpecialPowers.isContentWindowPrivate(win));
+ win.close();
+</script>
diff --git a/embedding/test/test_window_open_position_constraint.html b/embedding/test/test_window_open_position_constraint.html
new file mode 100644
index 0000000000..d2c777c74b
--- /dev/null
+++ b/embedding/test/test_window_open_position_constraint.html
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for Bug 978847</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=978847">Mozilla Bug 978847</a>
+<p id="display"></p>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+SimpleTest.waitForFocus(function() {
+ var x;
+ var y;
+
+ // window should be constrained to the screen rect,
+ // which we assume is less than 10000px square
+ var w1 = window.open("about:blank", "", "left=16000,top=16000,width=100,height=100");
+ SimpleTest.waitForFocus(function() {
+ ok(w1.screenX < 10000 && w1.screenY < 10000,
+ "window should not be opened off-screen: got location " +
+ w1.screenX + "," + w1.screenY);
+ x = w1.screenX;
+ y = w1.screenY;
+ w1.close();
+
+ // larger window dimensions should result in a shift of the constrained location
+ var w2 = window.open("about:blank", "", "left=16000,top=16000,width=150,height=150");
+ SimpleTest.waitForFocus(function() {
+ ok(w2.screenX == x - 50 && w2.screenY == y - 50,
+ "constrained window position did not depend on size as expected: got " +
+ w2.screenX + "," + w2.screenY + ", expected " + (x - 50) + "," + (y - 50));
+ w2.close();
+
+ // now try with coordinates that are close to MAXINT,
+ // so adding width/height risks 32-bit integer overflow
+ var w3 = window.open("about:blank", "", "left=2147483600,top=2147483600,width=100,height=100");
+ SimpleTest.waitForFocus(function() {
+ ok(w3.screenX < 10000 && w3.screenY < 10000,
+ "window should not be opened off-screen: got location " +
+ w3.screenX + "," + w3.screenY);
+ w3.close();
+ SimpleTest.finish();
+ }, w3, true);
+ }, w2, true);
+ }, w1, true);
+}, window, false);
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/embedding/test/test_window_open_units.html b/embedding/test/test_window_open_units.html
new file mode 100644
index 0000000000..a27a619664
--- /dev/null
+++ b/embedding/test/test_window_open_units.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for Bug 594140</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=594140">Mozilla Bug 594140</a>
+<p id="display"></p>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+SimpleTest.waitForFocus(function() {
+ SpecialPowers.setFullZoom(window, 2);
+
+ var p = window;
+ var w = window.open("about:blank", "", "width=200,height=100");
+ SimpleTest.waitForFocus(function() {
+ ok(w.innerWidth <= 402 && w.innerWidth >= 398,
+ "width (" + w.innerWidth + ") should be around twice what was requested (200)");
+ ok(w.innerHeight <= 202 && w.innerHeight >= 198,
+ "height (" + w.innerHeight + ") should be around twice what was requested (100)");
+
+ SpecialPowers.setFullZoom(window, 1);
+ w.close();
+ SimpleTest.finish();
+ }, w, true);
+}, window, false);
+
+</script>
+</pre>
+</body>
+</html>