Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: qunit/tests/url.js

Issue 29795579: Issue 6715 - Fix the url qunit tests. (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created May 31, 2018, 8:02 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: qunit/tests/url.js
===================================================================
--- a/qunit/tests/url.js
+++ b/qunit/tests/url.js
@@ -13,37 +13,35 @@
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
{
- let {getDecodedHostname,
- extractHostFromFrame,
- stringifyURL,
+ let {extractHostFromFrame,
isThirdParty} = require("../../lib/url");
QUnit.module("URL/host tools");
test("Extracting hostname from URL", () =>
{
function testURLHostname(url, expectedHostname, message)
{
- equal(getDecodedHostname(new URL(url)), expectedHostname, message);
+ equal(new URL(url).hostname, expectedHostname, message);
}
testURLHostname("http://example.com/foo", "example.com", "with path");
testURLHostname("http://example.com/?foo=bar", "example.com", "with query");
testURLHostname("http://example.com/#top", "example.com", "with hash");
testURLHostname("http://example.com:8080/", "example.com", "with port");
testURLHostname("http://user:password@example.com/", "example.com",
"with auth credentials");
- testURLHostname("http://xn--f-1gaa.com/", "f\u00f6\u00f6.com",
+ testURLHostname("http://xn--f-1gaa.com/", "xn--f-1gaa.com",
"with punycode");
testURLHostname("about:blank", "", "about:blank");
testURLHostname("data:text/plain,foo", "", "data: URL");
testURLHostname("ftp://example.com/", "example.com", "ftp: URL");
testURLHostname("http://1.2.3.4:8000/", "1.2.3.4", "IPv4 address");
testURLHostname("http://[2001:db8:85a3::8a2e:370:7334]/",
"[2001:db8:85a3::8a2e:370:7334]", "IPv6 address");
});
@@ -64,62 +62,36 @@
testFrameHostname(["http://example.com/", "http://example.org/"],
"example.org", "with parent frame");
testFrameHostname(["http://example.com/", "data:text/plain,foo"],
"example.com", "data: URL, hostname in parent");
testFrameHostname(["http://example.com/", "about:blank", "about:blank"],
"example.com", "about:blank, hostname in ancestor");
testFrameHostname(["about:blank", "about:blank"], "",
"about:blank, no hostname");
- testFrameHostname(["http://xn--f-1gaa.com/"], "f\u00f6\u00f6.com",
+ testFrameHostname(["http://xn--f-1gaa.com/"], "xn--f-1gaa.com",
"with punycode");
});
- test("Stringifying URLs", () =>
- {
- function testNormalizedURL(url, expectedURL, message)
- {
- equal(stringifyURL(new URL(url)), expectedURL, message);
- }
-
- function testPreservedURL(url, message)
- {
- testNormalizedURL(url, url, message);
- }
-
- testPreservedURL("http://example.com/foo", "includes path");
- testPreservedURL("http://example.com/?foo=bar", "includes query");
- testPreservedURL("http://example.com:8080/", "includes port");
- testPreservedURL("http://example.com/?", "with empty query string");
- testNormalizedURL("http://example.com/#top", "http://example.com/",
- "stripped hash");
- testNormalizedURL("http://example.com/#top?", "http://example.com/",
- "stripped hash with trailing question mark");
- testNormalizedURL("http://xn--f-1gaa.com/", "http://f\u00f6\u00f6.com/",
- "decoded punycode");
- testPreservedURL("about:blank", "about:blank");
- testPreservedURL("data:text/plain,foo", "data: URL");
- });
-
test("Third-party checks", () =>
{
function hostnameToURL(hostname)
{
return new URL("http://" + hostname);
}
function testThirdParty(requestHost, documentHost, expected, message)
{
equal(
isThirdParty(
hostnameToURL(requestHost),
// Chrome's URL object normalizes IP addresses. So some test
// will fail if we don't normalize the document host as well.
- getDecodedHostname(hostnameToURL(documentHost))
+ hostnameToURL(documentHost).hostname
),
expected,
message
);
}
testThirdParty("foo", "foo", false, "same domain isn't third-party");
testThirdParty("foo", "bar", true, "different domain is third-party");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld