Bug 1254592 - [e10s] fix test_history_post.xul to run in content and remove duped test_bug_94514.html. r=mak
MozReview-Commit-ID: 1CsaPl2WiX
--- a/toolkit/components/places/tests/browser/browser.ini
+++ b/toolkit/components/places/tests/browser/browser.ini
@@ -12,15 +12,16 @@ support-files =
[browser_bug646422.js]
[browser_bug680727.js]
skip-if = buildapp == 'mulet' # Bug ?????? - test times out on try on all platforms, but works locally for markh!
[browser_colorAnalyzer.js]
[browser_double_redirect.js]
[browser_favicon_privatebrowsing_perwindowpb.js]
[browser_favicon_setAndFetchFaviconForPage.js]
[browser_favicon_setAndFetchFaviconForPage_failures.js]
+[browser_history_post.js]
[browser_notfound.js]
[browser_redirect.js]
[browser_settitle.js]
[browser_visited_notfound.js]
[browser_visituri.js]
[browser_visituri_nohistory.js]
[browser_visituri_privatebrowsing_perwindowpb.js]
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/toolkit/components/places/tests/browser/browser_history_post.js
@@ -0,0 +1,28 @@
+const PAGE_URI = "http://example.com/tests/toolkit/components/places/tests/browser/history_post.html";
+const SJS_URI = NetUtil.newURI("http://example.com/tests/toolkit/components/places/tests/browser/history_post.sjs");
+
+add_task(function* () {
+ yield BrowserTestUtils.withNewTab({gBrowser, url: PAGE_URI}, Task.async(function* (aBrowser) {
+ yield ContentTask.spawn(aBrowser, null, function* () {
+ let doc = content.document;
+ let submit = doc.getElementById("submit");
+ let iframe = doc.getElementById("post_iframe");
+ let p = new Promise((resolve, reject) => {
+ iframe.addEventListener("load", function onLoad() {
+ iframe.removeEventListener("load", onLoad);
+ resolve();
+ });
+ });
+ submit.click();
+ yield p;
+ });
+ let visited = yield promiseIsURIVisited(SJS_URI);
+ ok(!visited, "The POST page should not be added to history");
+ let db = yield PlacesUtils.promiseDBConnection();
+ let rows = yield db.execute(
+ "SELECT 1 FROM moz_places WHERE url = :page_url",
+ {page_url: SJS_URI.spec});
+ is(rows.length, 0, "The page should not be in the database");
+ yield db.close();
+ }));
+});
new file mode 100644
--- /dev/null
+++ b/toolkit/components/places/tests/browser/history_post.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Test post pages are not added to history</title>
+ </head>
+ <body>
+ <iframe name="post_iframe" id="post_iframe"></iframe>
+ <form method="post" action="http://example.com/tests/toolkit/components/places/tests/browser/history_post.sjs" target="post_iframe">
+ <input type="submit" id="submit"/>
+ </form>
+ </body>
+</html>
rename from toolkit/components/places/tests/chrome/history_post.sjs
rename to toolkit/components/places/tests/browser/history_post.sjs
deleted file mode 100644
--- a/toolkit/components/places/tests/bug94514-postpage.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=94514
-Specifically, this is a test page that actually submits a form.
--->
-<head>
- <title>Test Page for Bug 94515</title>
-</head>
-<body>
-<form id="testForm" method="POST">
- <input type="submit" id="send"/>
-</form>
-
-<script class="testbody" type="text/javascript">
-
-if (!window.location.href.match("posted=1")) {
- // Here we just submit the form
- var form = document.getElementById("testForm");
- form.action = window.location.href + "?posted=1";
- form.submit();
-} else {
- window.location.href = "http://mochi.test:8888/tests/toolkit/components/places/tests/bug94514-postpage.html";
-}
-
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/toolkit/components/places/tests/chrome.ini
+++ /dev/null
@@ -1,1 +0,0 @@
-[test_bug_94514.html]
--- a/toolkit/components/places/tests/chrome/chrome.ini
+++ b/toolkit/components/places/tests/chrome/chrome.ini
@@ -1,13 +1,11 @@
[DEFAULT]
skip-if = buildapp == 'b2g'
-support-files = history_post.sjs
[test_303567.xul]
[test_341972a.xul]
[test_341972b.xul]
[test_342484.xul]
[test_371798.xul]
[test_381357.xul]
[test_favicon_annotations.xul]
-[test_history_post.xul]
[test_reloadLivemarks.xul]
deleted file mode 100644
--- a/toolkit/components/places/tests/chrome/test_history_post.xul
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- 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/. -->
-
-<window title="Test post pages are not added to history"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- onload="test();">
-
- <script type="application/javascript"
- src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
- <script type="application/javascript"
- src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"/>
- <script type="application/javascript"
- src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
-
- <script type="application/javascript">
- <![CDATA[
-
- const Cc = Components.classes;
- const Ci = Components.interfaces;
-
- Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
- Components.utils.import("resource://gre/modules/NetUtil.jsm");
-
- const SJS_URI = NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/history_post.sjs");
-
- function test()
- {
- SimpleTest.waitForExplicitFinish();
- let submit = document.getElementById("submit");
- submit.click();
- let iframe = document.getElementById("post_iframe");
- iframe.addEventListener("load", function onLoad() {
- iframe.removeEventListener("load", onLoad);
- let history = Cc["@mozilla.org/browser/history;1"]
- .getService(Ci.mozIAsyncHistory);
- history.isURIVisited(SJS_URI, function (aURI, aIsVisited) {
- ok(!aIsVisited, "The POST page should not be added to history");
-
- let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
- .DBConnection;
- let stmt = db.createStatement(
- "SELECT 1 FROM moz_places WHERE url = :page_url"
- );
- stmt.params.page_url = SJS_URI.spec;
- ok(!stmt.executeStep(), "The page should not be in the database");
- stmt.finalize();
- SimpleTest.finish();
- });
- });
- }
-
- ]]>
- </script>
-
- <body xmlns="http://www.w3.org/1999/xhtml">
- <iframe name="post_iframe" id="post_iframe"/>
- <form method="post" action="http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/history_post.sjs" target="post_iframe">
- <input type="submit" id="submit"/>
- </form>
- <p id="display"></p>
- <div id="content" style="display:none;"></div>
- <pre id="test"></pre>
- </body>
-</window>
--- a/toolkit/components/places/tests/moz.build
+++ b/toolkit/components/places/tests/moz.build
@@ -21,17 +21,16 @@ XPCSHELL_TESTS_MANIFESTS += [
'network/xpcshell.ini',
'queries/xpcshell.ini',
'unifiedcomplete/xpcshell.ini',
'unit/xpcshell.ini',
]
BROWSER_CHROME_MANIFESTS += ['browser/browser.ini']
MOCHITEST_CHROME_MANIFESTS += [
- 'chrome.ini',
'chrome/chrome.ini',
]
TEST_HARNESS_FILES.xpcshell.toolkit.components.places.tests += [
'head_common.js',
]
TEST_HARNESS_FILES.testing.mochitest.tests.toolkit.components.places.tests.browser += [
@@ -46,16 +45,18 @@ TEST_HARNESS_FILES.testing.mochitest.tes
'browser/461710_link_page-3.html',
'browser/461710_link_page.html',
'browser/461710_visited_page.html',
'browser/begin.html',
'browser/favicon-normal16.png',
'browser/favicon-normal32.png',
'browser/favicon.html',
'browser/final.html',
+ 'browser/history_post.html',
+ 'browser/history_post.sjs',
'browser/redirect-target.html',
'browser/redirect.sjs',
'browser/redirect_once.sjs',
'browser/redirect_twice.sjs',
'browser/title1.html',
'browser/title2.html',
]
@@ -63,12 +64,8 @@ TEST_HARNESS_FILES.testing.mochitest.tes
'chrome/bad_links.atom',
'chrome/link-less-items-no-site-uri.rss',
'chrome/link-less-items.rss',
'chrome/rss_as_html.rss',
'chrome/rss_as_html.rss^headers^',
'chrome/sample_feed.atom',
]
-TEST_HARNESS_FILES.testing.mochitest.tests.toolkit.components.places.tests += [
- 'bug94514-postpage.html',
-]
-
deleted file mode 100644
--- a/toolkit/components/places/tests/test_bug_94514.html
+++ /dev/null
@@ -1,79 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=94514
-Specifically, this tests that a page that is obtained via a post request does
-not get added to global history.
--->
-<head>
- <title>Test for Bug 94515</title>
- <script type="text/javascript" src="http://mochi.test:8888/tests/SimpleTest/SimpleTest.js"></script>
-
- <link rel="stylesheet" type="text/css" href="http://mochi.test:8888/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=94514">Mozilla Bug 94514</a>
-
-<div id="content" style="display: none">
-
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-SimpleTest.waitForExplicitFinish();
-
-var startURI = "http://mochi.test:8888/tests/toolkit/components/places/tests/bug94514-postpage.html";
-var postedURI = startURI + "?posted=1";
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
-
-var ios = Cc["@mozilla.org/network/io-service;1"].
- getService(Ci.nsIIOService);
-var startPage = ios.newURI(startURI, null, null);
-var postedPage = ios.newURI(postedURI, null, null);
-var w = null;
-
-// Because adding visits is async, we will not be notified imemdiately.
-var os = Cc["@mozilla.org/observer-service;1"].
- getService(Ci.nsIObserverService);
-var visitObserver = {
- _visitCount: 0,
- observe: function(aSubject, aTopic, aData) {
- if (!startPage.equals(aSubject.QueryInterface(Ci.nsIURI)) ||
- ++this._visitCount < 2) {
- return;
- }
- os.removeObserver(this, aTopic);
- finishTest();
- },
-};
-os.addObserver(visitObserver, "uri-visit-saved", false);
-
-PlacesUtils.asyncHistory.isURIVisited(startPage, function(aURI, aIsVisited) {
- SimpleTest.ok(!aIsVisited, "Initial page does not start in global history. " +
- "Note: this will also fail if you run the test twice.");
- PlacesUtils.asyncHistory.isURIVisited(postedPage, function(aURI, aIsVisited) {
- SimpleTest.ok(!aIsVisited, "Posted page does not start in global history.");
- w = window.open(startURI, "", "width=10,height=10");
- });
-});
-
-function finishTest() {
- // We need to check that this was not added to global history.
- PlacesUtils.asyncHistory.isURIVisited(startPage, function(aURI, aIsVisited) {
- SimpleTest.ok(aIsVisited, "Initial page was added to global history.");
- PlacesUtils.asyncHistory.isURIVisited(postedPage, function(aURI, aIsVisited) {
- SimpleTest.ok(!aIsVisited, "Posted page was not added to global history.");
- w.close();
- SimpleTest.finish();
- });
- });
-}
-
-</script>
-</pre>
-</body>
-</html>