https://bugs.webkit.org/show_bug.cgi?id=161176 assumes everything is UTF8. This is progress, but not correct. Sometimes the Document's TextEncoding should be used. This should make even more web platform tests pass.
See https://github.com/w3c/web-platform-tests/pull/10915 for additional test coverage here and https://github.com/whatwg/url/pull/386 for a change to the URL Standard that tweaks the details here to make things better for web developers.
As of some time ago, assuming everything is UTF-8 is correct for the query/search setter. I fixed the remaining tests in https://github.com/web-platform-tests/wpt/commit/8236142e9de79b5f9b4d97b086d4b1bf5c6a3ce4.