 Issue 29371763:
  Issue 4795 - Use modern JavaScript syntax  (Closed)
    
  
    Issue 29371763:
  Issue 4795 - Use modern JavaScript syntax  (Closed) 
  | Index: qunit/tests/url.js | 
| diff --git a/qunit/tests/url.js b/qunit/tests/url.js | 
| index 1b504cb70d7442a8f5cbfa086266fec9bc19dfaf..6168e75a9ffb90a62e6c8494e63789f2fdb2403b 100644 | 
| --- a/qunit/tests/url.js | 
| +++ b/qunit/tests/url.js | 
| @@ -15,18 +15,18 @@ | 
| * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| */ | 
| +"use strict"; | 
| -(function() | 
| { | 
| - var url = require("url"); | 
| - var getDecodedHostname = url.getDecodedHostname; | 
| - var extractHostFromFrame = url.extractHostFromFrame; | 
| - var stringifyURL = url.stringifyURL; | 
| - var isThirdParty = url.isThirdParty; | 
| + let url = require("url"); | 
| 
Sebastian Noack
2017/01/16 15:35:57
I suppose we could better use destructuring here n
 
kzar
2017/01/17 07:42:50
Done.
 | 
| + let getDecodedHostname = url.getDecodedHostname; | 
| + let extractHostFromFrame = url.extractHostFromFrame; | 
| + let stringifyURL = url.stringifyURL; | 
| + let isThirdParty = url.isThirdParty; | 
| module("URL/host tools"); | 
| - test("Extracting hostname from URL", function() | 
| + test("Extracting hostname from URL", () => | 
| { | 
| function testURLHostname(url, expectedHostname, message) | 
| { | 
| @@ -46,14 +46,14 @@ | 
| testURLHostname("http://[2001:db8:85a3::8a2e:370:7334]/", "[2001:db8:85a3::8a2e:370:7334]", "IPv6 address"); | 
| }); | 
| - test("Extracting hostname from frame", function() | 
| + test("Extracting hostname from frame", () => | 
| { | 
| function testFrameHostname(hierarchy, expectedHostname, message) | 
| { | 
| - var frame = null; | 
| + let frame = null; | 
| - for (var i = 0; i < hierarchy.length; i++) | 
| - frame = {parent: frame, url: new URL(hierarchy[i])}; | 
| + for (let url of hierarchy) | 
| + frame = {parent: frame, url: new URL(url)}; | 
| equal(extractHostFromFrame(frame), expectedHostname, message); | 
| } | 
| @@ -66,7 +66,7 @@ | 
| testFrameHostname(["http://xn--f-1gaa.com/"], "f\u00f6\u00f6.com", "with punycode"); | 
| }); | 
| - test("Stringifying URLs", function() | 
| + test("Stringifying URLs", () => | 
| { | 
| function testNormalizedURL(url, expectedURL, message) | 
| { | 
| @@ -89,7 +89,7 @@ | 
| testPreservedURL("data:text/plain,foo", "data: URL"); | 
| }); | 
| - test("Third-party checks", function() | 
| + test("Third-party checks", () => | 
| { | 
| function hostnameToURL(hostname) | 
| { | 
| @@ -134,4 +134,4 @@ | 
| testThirdParty("xn--f-1gaa.com", "f\u00f6\u00f6.com", false, "same IDN isn't third-party"); | 
| testThirdParty("example.com..", "example.com....", false, "traling dots are ignored"); | 
| }); | 
| -})(); | 
| +} |