| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; |
| 18 | 19 |
| 19 { | 20 { |
| 20 let url = require("url"); | 21 let {getDecodedHostname, |
| 21 let getDecodedHostname = url.getDecodedHostname; | 22 extractHostFromFrame, |
| 22 let extractHostFromFrame = url.extractHostFromFrame; | 23 stringifyURL, |
| 23 let stringifyURL = url.stringifyURL; | 24 isThirdParty} = require("url"); |
| 24 let isThirdParty = url.isThirdParty; | |
| 25 | 25 |
| 26 module("URL/host tools"); | 26 module("URL/host tools"); |
| 27 | 27 |
| 28 test("Extracting hostname from URL", () => | 28 test("Extracting hostname from URL", () => |
| 29 { | 29 { |
| 30 function testURLHostname(url, expectedHostname, message) | 30 function testURLHostname(url, expectedHostname, message) |
| 31 { | 31 { |
| 32 equal(getDecodedHostname(new URL(url)), expectedHostname, message); | 32 equal(getDecodedHostname(new URL(url)), expectedHostname, message); |
| 33 } | 33 } |
| 34 | 34 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 testThirdParty("1.0xff.1.1", "2.0xff.1.1", true, "different IPv4 address wit
h hexadecimal octet is third-party"); | 127 testThirdParty("1.0xff.1.1", "2.0xff.1.1", true, "different IPv4 address wit
h hexadecimal octet is third-party"); |
| 128 testThirdParty("0xff.example.com", "example.com", false, "domain starts like
a hexadecimal IPv4 address but isn't one"); | 128 testThirdParty("0xff.example.com", "example.com", false, "domain starts like
a hexadecimal IPv4 address but isn't one"); |
| 129 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[2001:db8:85a3::8a2e:370:7
334]", false, "same IPv6 address isn't third-party"); | 129 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[2001:db8:85a3::8a2e:370:7
334]", false, "same IPv6 address isn't third-party"); |
| 130 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[5001:db8:85a3::8a2e:370:7
334]", true, "different IPv6 address is third-party"); | 130 testThirdParty("[2001:db8:85a3::8a2e:370:7334]", "[5001:db8:85a3::8a2e:370:7
334]", true, "different IPv6 address is third-party"); |
| 131 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.0.2.128]", false, "same
IPv4-mapped IPv6 address isn't third-party"); | 131 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.0.2.128]", false, "same
IPv4-mapped IPv6 address isn't third-party"); |
| 132 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.1.2.128]", true, "differ
ent IPv4-mapped IPv6 address is third-party"); | 132 testThirdParty("[::ffff:192.0.2.128]", "[::ffff:192.1.2.128]", true, "differ
ent IPv4-mapped IPv6 address is third-party"); |
| 133 testThirdParty("xn--f-1gaa.com", "f\u00f6\u00f6.com", false, "same IDN isn't
third-party"); | 133 testThirdParty("xn--f-1gaa.com", "f\u00f6\u00f6.com", false, "same IDN isn't
third-party"); |
| 134 testThirdParty("example.com..", "example.com....", false, "traling dots are
ignored"); | 134 testThirdParty("example.com..", "example.com....", false, "traling dots are
ignored"); |
| 135 }); | 135 }); |
| 136 } | 136 } |
| LEFT | RIGHT |