1'use strict'; 2 3// Tests below are not from WPT. 4 5require('../common'); 6const assert = require('assert'); 7 8{ 9 const params = new URLSearchParams(); 10 assert.throws(() => { 11 params.toString.call(undefined); 12 }, { 13 code: 'ERR_INVALID_THIS', 14 name: 'TypeError', 15 message: 'Value of "this" must be of type URLSearchParams' 16 }); 17} 18 19// The URLSearchParams stringifier mutates the base URL using 20// different percent-encoding rules than the URL itself. 21{ 22 const myUrl = new URL('https://example.org?foo=~bar'); 23 assert.strictEqual(myUrl.search, '?foo=~bar'); 24 myUrl.searchParams.sort(); 25 assert.strictEqual(myUrl.search, '?foo=%7Ebar'); 26} 27