mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-14 04:03:47 +00:00
Bug 1172165 - test changes: remove broken bit of test for view-source linking now that it is completely disallowed, and fix html parser's view-source test, r=bz
--HG-- rename : parser/htmlparser/tests/mochitest/test_viewsource.html => parser/htmlparser/tests/mochitest/file_viewsource.html extra : commitid : IVqN6XUYvOk extra : rebase_source : 62b723f641b2c2843080ef7f586df1236237241c
This commit is contained in:
parent
2c2030d252
commit
1839ec6c66
@ -164,18 +164,6 @@ var gTests = [
|
||||
"pokes" : { },
|
||||
"func" : anchorTest,
|
||||
},
|
||||
{ "name" : "iframes.html loaded from view-source jar type, pref disabled",
|
||||
"url" : "jar:view-source:http://mochi.test:8888/tests/docshell/test/bug369814.jar!/iframes.html",
|
||||
"pref" : false,
|
||||
"pokes" : { },
|
||||
"func" : loadErrorTest
|
||||
},
|
||||
{ "name" : "iframes.html loaded from view-source jar type, pref enabled",
|
||||
"url" : "jar:view-source:http://mochi.test:8888/tests/docshell/test/bug369814.jar!/iframes.html",
|
||||
"pref" : true,
|
||||
"pokes" : { },
|
||||
"func" : loadErrorTest
|
||||
},
|
||||
];
|
||||
|
||||
var gNextTest = 0;
|
||||
|
@ -5,6 +5,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini']
|
||||
BROWSER_CHROME_MANIFESTS += ['tests/mochitest/browser.ini']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIExpatSink.idl',
|
||||
|
7
parser/htmlparser/tests/mochitest/browser.ini
Normal file
7
parser/htmlparser/tests/mochitest/browser.ini
Normal file
@ -0,0 +1,7 @@
|
||||
[DEFAULT]
|
||||
skip-if = buildapp == 'b2g'
|
||||
|
||||
[browser_viewsource.js]
|
||||
support-files =
|
||||
file_viewsource.html
|
||||
|
22
parser/htmlparser/tests/mochitest/browser_viewsource.js
Normal file
22
parser/htmlparser/tests/mochitest/browser_viewsource.js
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
add_task(function*() {
|
||||
const PAGE_URL = getRootDirectory(gTestPath) + "file_viewsource.html";
|
||||
let viewSourceTab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "view-source:" + PAGE_URL);
|
||||
|
||||
let xhrPromise = new Promise(resolve => {
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", PAGE_URL, true);
|
||||
xhr.onload = event => resolve(event.target.responseText);
|
||||
xhr.send();
|
||||
});
|
||||
|
||||
let viewSourceContentPromise = ContentTask.spawn(viewSourceTab.linkedBrowser, null, function*() {
|
||||
return content.document.body.textContent;
|
||||
});
|
||||
|
||||
let results = yield Promise.all([viewSourceContentPromise, xhrPromise]);
|
||||
is(results[0], results[1], "Sources should match");
|
||||
yield BrowserTestUtils.removeTab(viewSourceTab);
|
||||
});
|
||||
|
18
parser/htmlparser/tests/mochitest/file_viewsource.html
Normal file
18
parser/htmlparser/tests/mochitest/file_viewsource.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for view source</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--
|
||||
this is a multi-line comment
|
||||
-->
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
// This is a script comment / text.
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -140,7 +140,6 @@ skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_html5_tree_construction_part2.html]
|
||||
skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_img_picture_preload.html]
|
||||
[test_viewsource.html]
|
||||
[test_xml_mislabeled.html]
|
||||
# Disabled test due to orange on Linux
|
||||
# test_bug568470.html
|
||||
|
@ -1,50 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for view source</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--
|
||||
this is a multi-line comment
|
||||
-->
|
||||
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// Return the source text of the document at the given URL.
|
||||
function fetch(url) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", url, false); // None of this async silliness,
|
||||
xhr.send(); // we'll just wait.
|
||||
return xhr.responseText;
|
||||
}
|
||||
|
||||
// We will "view" the source of the document in a new window.
|
||||
// If everything is working correctly, the "source" will simply be the
|
||||
// text content of the new window's document's body element.
|
||||
// We have to use a window as view-source: is only allowed in top level,
|
||||
// see bug 624883.
|
||||
|
||||
// Open the new window.
|
||||
var windowWithSource = window.open("about:blank");
|
||||
|
||||
// The actual test will be carried out inside the window's onload handler.
|
||||
windowWithSource.onload = function () {
|
||||
var apparentSource = this.document.body.textContent;
|
||||
var actualSource = fetch(location.href);
|
||||
is(apparentSource, actualSource, "Sources should match");
|
||||
|
||||
windowWithSource.close()
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
windowWithSource.location.href = "view-source:" + location.href;
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user