| Left: | ||
| Right: |
| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 "use strict"; |
| 19 | 19 |
| 20 { | 20 { |
| 21 const {extractHostFromFrame, | 21 const {extractHostFromFrame, isThirdParty} = require("../../lib/url"); |
|
geo
2018/09/06 10:24:10
I know that this change is not related to this par
Sebastian Noack
2018/09/06 13:43:21
I agree, but while on it, it also seems unnecessar
geo
2018/09/06 20:10:47
You're right. I was so focused on that let and con
| |
| 22 isThirdParty} = require("../../lib/url"); | |
| 23 const {platform} = require("info"); | 22 const {platform} = require("info"); |
| 24 | 23 |
| 25 QUnit.module("URL/host tools"); | 24 QUnit.module("URL/host tools"); |
| 26 | 25 |
| 27 test("Extracting hostname from frame", () => | 26 test("Extracting hostname from frame", () => |
| 28 { | 27 { |
| 29 function testFrameHostname(hierarchy, expectedHostname, message) | 28 function testFrameHostname(hierarchy, expectedHostname, message) |
| 30 { | 29 { |
| 31 let frame = null; | 30 let frame = null; |
| 32 | 31 |
| 33 for (let url of hierarchy) | 32 for (let url of hierarchy) |
| 34 frame = {parent: frame, url: new URL(url)}; | 33 frame = {parent: frame, url: new URL(url)}; |
| 35 | 34 |
| 36 equal(extractHostFromFrame(frame), expectedHostname, message); | 35 equal(extractHostFromFrame(frame), expectedHostname, message); |
| 37 } | 36 } |
| 38 | 37 |
| 39 testFrameHostname(["http://example.com/"], "example.com", "single frame"); | 38 testFrameHostname(["http://example.com/"], "example.com", "single frame"); |
| 40 testFrameHostname(["http://example.com/", "http://example.org/"], | 39 testFrameHostname(["http://example.com/", "http://example.org/"], |
| 41 "example.org", "with parent frame"); | 40 "example.org", "with parent frame"); |
| 42 testFrameHostname(["http://example.com/", "data:text/plain,foo"], | 41 testFrameHostname(["http://example.com/", "data:text/plain,foo"], |
| 43 "example.com", "data: URL, hostname in parent"); | 42 "example.com", "data: URL, hostname in parent"); |
| 44 testFrameHostname(["http://example.com/", "about:blank", "about:blank"], | 43 testFrameHostname(["http://example.com/", "about:blank", "about:blank"], |
| 45 "example.com", "about:blank, hostname in ancestor"); | 44 "example.com", "about:blank, hostname in ancestor"); |
| 46 testFrameHostname(["about:blank", "about:blank"], "", | 45 testFrameHostname(["about:blank", "about:blank"], "", |
| 47 "about:blank, no hostname"); | 46 "about:blank, no hostname"); |
| 47 | |
| 48 // Currently there are two bugs in Microsoft Edge (EdgeHTML 17.17134) | 48 // Currently there are two bugs in Microsoft Edge (EdgeHTML 17.17134) |
|
Sebastian Noack
2018/09/06 13:43:21
Nit: It might read better with a blank line above.
geo
2018/09/06 20:10:47
Done.
| |
| 49 // that would make this two assertions fail, | 49 // that would make this two assertions fail, |
| 50 // so for now we are not running them on this platform. | 50 // so for now we are not running them on this platform. |
| 51 // See: https://issues.adblockplus.org/ticket/6913 | 51 // See: |
|
Sebastian Noack
2018/09/06 13:43:21
Can we link to the Microsoft Edge bugs directly, r
geo
2018/09/06 20:10:47
Done.
| |
| 52 // with punycode: https://developer.microsoft.com/en-us/microsoft-edge/platf orm/issues/18861990/ | |
| 53 // with auth credentials: https://developer.microsoft.com/en-us/microsoft-ed ge/platform/issues/8004284/ | |
| 52 if (platform != "edgehtml") | 54 if (platform != "edgehtml") |
| 53 { | 55 { |
| 54 testFrameHostname(["http://xn--f-1gaa.com/"], "xn--f-1gaa.com", | 56 testFrameHostname(["http://xn--f-1gaa.com/"], "xn--f-1gaa.com", |
| 55 "with punycode"); | 57 "with punycode"); |
| 56 testFrameHostname(["http://user:password@example.com/"], "example.com", | 58 testFrameHostname(["http://user:password@example.com/"], "example.com", |
| 57 "with auth credentials"); | 59 "with auth credentials"); |
| 58 } | 60 } |
| 59 }); | 61 }); |
| 60 | 62 |
| 61 test("Third-party checks", () => | 63 test("Third-party checks", () => |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 testThirdParty( | 133 testThirdParty( |
| 132 "[::ffff:192.0.2.128]", "[::ffff:192.1.2.128]", true, | 134 "[::ffff:192.0.2.128]", "[::ffff:192.1.2.128]", true, |
| 133 "different IPv4-mapped IPv6 address is third-party" | 135 "different IPv4-mapped IPv6 address is third-party" |
| 134 ); | 136 ); |
| 135 testThirdParty("xn--f-1gaa.com", "f\u00f6\u00f6.com", false, | 137 testThirdParty("xn--f-1gaa.com", "f\u00f6\u00f6.com", false, |
| 136 "same IDN isn't third-party"); | 138 "same IDN isn't third-party"); |
| 137 testThirdParty("example.com..", "example.com....", false, | 139 testThirdParty("example.com..", "example.com....", false, |
| 138 "traling dots are ignored"); | 140 "traling dots are ignored"); |
| 139 }); | 141 }); |
| 140 } | 142 } |
| LEFT | RIGHT |