Bug 162254

Summary: Non-special URLs should have an opaque origin
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, benjamin, buildbot, cdumez, cgarcia, cmarcelo, commit-queue, eric.carlson, ews-watchlist, ggaren, glenn, hi, jer.noble, mcatanzaro, mike, philipj, rniwa, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=162387
https://bugs.webkit.org/show_bug.cgi?id=162475
https://bugs.webkit.org/show_bug.cgi?id=222943
https://bugs.webkit.org/show_bug.cgi?id=225036
Bug Depends on: 162492    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews101 for mac-yosemite
none
Archive of layout-test-results from ews117 for mac-yosemite
none
Archive of layout-test-results from ews107 for mac-yosemite-wk2
none
Patch
none
Archive of layout-test-results from ews101 for mac-yosemite
none
Archive of layout-test-results from ews104 for mac-yosemite-wk2
none
Archive of layout-test-results from ews117 for mac-yosemite
none
Patch
none
Archive of layout-test-results from ews103 for mac-yosemite
none
Archive of layout-test-results from ews107 for mac-yosemite-wk2
none
Archive of layout-test-results from ews117 for mac-yosemite
none
Archive of layout-test-results from ews123 for ios-simulator-elcapitan-wk2
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
[Image] screenshot of current behavior of custom origin in Web Inspector
none
Patch
none
Patch none

Alex Christensen
Reported 2016-09-19 21:58:48 PDT
Non-special URLs should have an opaque origin
Attachments
Patch (47.75 KB, patch)
2016-09-19 22:00 PDT, Alex Christensen
no flags
Archive of layout-test-results from ews101 for mac-yosemite (892.22 KB, application/zip)
2016-09-19 22:19 PDT, Build Bot
no flags
Archive of layout-test-results from ews117 for mac-yosemite (330.73 KB, application/zip)
2016-09-19 22:37 PDT, Build Bot
no flags
Archive of layout-test-results from ews107 for mac-yosemite-wk2 (368.89 KB, application/zip)
2016-09-19 22:37 PDT, Build Bot
no flags
Patch (47.60 KB, patch)
2016-09-20 08:11 PDT, Alex Christensen
no flags
Archive of layout-test-results from ews101 for mac-yosemite (799.26 KB, application/zip)
2016-09-20 08:51 PDT, Build Bot
no flags
Archive of layout-test-results from ews104 for mac-yosemite-wk2 (1.03 MB, application/zip)
2016-09-20 08:57 PDT, Build Bot
no flags
Archive of layout-test-results from ews117 for mac-yosemite (741.07 KB, application/zip)
2016-09-20 08:59 PDT, Build Bot
no flags
Patch (47.93 KB, patch)
2016-09-20 09:01 PDT, Alex Christensen
no flags
Archive of layout-test-results from ews103 for mac-yosemite (960.44 KB, application/zip)
2016-09-20 09:50 PDT, Build Bot
no flags
Archive of layout-test-results from ews107 for mac-yosemite-wk2 (951.52 KB, application/zip)
2016-09-20 09:59 PDT, Build Bot
no flags
Archive of layout-test-results from ews117 for mac-yosemite (1.49 MB, application/zip)
2016-09-20 10:04 PDT, Build Bot
no flags
Archive of layout-test-results from ews123 for ios-simulator-elcapitan-wk2 (7.85 MB, application/zip)
2016-09-20 10:11 PDT, Build Bot
no flags
Patch (50.80 KB, patch)
2016-09-20 10:59 PDT, Alex Christensen
no flags
Patch (87.11 KB, patch)
2016-10-14 18:47 PDT, Alex Christensen
no flags
Patch (86.95 KB, patch)
2020-11-06 10:32 PST, Alex Christensen
no flags
Patch (87.01 KB, patch)
2020-11-06 12:07 PST, Alex Christensen
no flags
Patch (88.31 KB, patch)
2020-11-06 13:19 PST, Alex Christensen
ews-feeder: commit-queue-
Patch (94.53 KB, patch)
2020-11-06 19:35 PST, Alex Christensen
no flags
Patch (97.96 KB, patch)
2020-11-10 07:51 PST, Alex Christensen
no flags
Patch (98.03 KB, patch)
2020-11-10 12:09 PST, Alex Christensen
no flags
[Image] screenshot of current behavior of custom origin in Web Inspector (37.76 KB, image/png)
2020-11-10 13:34 PST, Devin Rousso
no flags
Patch (97.43 KB, patch)
2020-11-12 09:11 PST, Alex Christensen
no flags
Patch (107.66 KB, patch)
2021-02-06 20:56 PST, Alex Christensen
no flags
Alex Christensen
Comment 1 2016-09-19 22:00:41 PDT
Build Bot
Comment 2 2016-09-19 22:19:21 PDT
Comment on attachment 289315 [details] Patch Attachment 289315 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/2110036 Number of test failures exceeded the failure limit.
Build Bot
Comment 3 2016-09-19 22:19:24 PDT
Created attachment 289322 [details] Archive of layout-test-results from ews101 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-yosemite Platform: Mac OS X 10.10.5
Build Bot
Comment 4 2016-09-19 22:37:47 PDT
Comment on attachment 289315 [details] Patch Attachment 289315 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/2110155 Number of test failures exceeded the failure limit.
Build Bot
Comment 5 2016-09-19 22:37:50 PDT
Created attachment 289323 [details] Archive of layout-test-results from ews117 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-yosemite Platform: Mac OS X 10.10.5
Build Bot
Comment 6 2016-09-19 22:37:57 PDT
Comment on attachment 289315 [details] Patch Attachment 289315 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/2110160 Number of test failures exceeded the failure limit.
Build Bot
Comment 7 2016-09-19 22:37:59 PDT
Created attachment 289324 [details] Archive of layout-test-results from ews107 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Sam Weinig
Comment 8 2016-09-20 02:34:06 PDT
Comment on attachment 289315 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=289315&action=review > Source/WebCore/page/SecurityOrigin.cpp:182 > + if (url.protocolIsInHTTPFamily() This could use a either a comment, or a helper predicate that explains why this set. I would prefer a static shouldUseUniqueOrigin(url) or something.
Alex Christensen
Comment 9 2016-09-20 08:11:37 PDT
Sam Weinig
Comment 10 2016-09-20 08:28:20 PDT
Comment on attachment 289345 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=289345&action=review I'm a little concerned that this is changing the behavior of file: URLs here, but I am honestly not sure what the old behavior was. Also, how does this differ from SchemeRegistry::shouldTreatURLSchemeAsNoAccess()? > Source/WebCore/page/SecurityOrigin.cpp:105 > + && !url.protocolIs("gopher") GOPHER!
Build Bot
Comment 11 2016-09-20 08:51:14 PDT
Comment on attachment 289345 [details] Patch Attachment 289345 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/2112734 Number of test failures exceeded the failure limit.
Build Bot
Comment 12 2016-09-20 08:51:17 PDT
Created attachment 289351 [details] Archive of layout-test-results from ews101 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-yosemite Platform: Mac OS X 10.10.5
Build Bot
Comment 13 2016-09-20 08:57:02 PDT
Comment on attachment 289345 [details] Patch Attachment 289345 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/2112742 Number of test failures exceeded the failure limit.
Build Bot
Comment 14 2016-09-20 08:57:05 PDT
Created attachment 289352 [details] Archive of layout-test-results from ews104 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 15 2016-09-20 08:59:32 PDT
Comment on attachment 289345 [details] Patch Attachment 289345 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/2112740 Number of test failures exceeded the failure limit.
Build Bot
Comment 16 2016-09-20 08:59:35 PDT
Created attachment 289353 [details] Archive of layout-test-results from ews117 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-yosemite Platform: Mac OS X 10.10.5
Alex Christensen
Comment 17 2016-09-20 09:01:32 PDT
Alex Christensen
Comment 18 2016-09-20 09:09:21 PDT
(In reply to comment #10) > Comment on attachment 289345 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=289345&action=review > > I'm a little concerned that this is changing the behavior of file: URLs > here, but I am honestly not sure what the old behavior was. Also, how does > this differ from SchemeRegistry::shouldTreatURLSchemeAsNoAccess()? File URLs are in the list of unchanged schemes. This makes it so all non-special schemes have opaque security origin. I guess SchemeRegistry::shouldTreatURLSchemeAsNoAccess could be used to make a scheme like http have opaque security origins, but I'm not sure if it's ever used for that. Maybe SchemeRegistry::shouldTreatURLSchemeAsNoAccess should be removed because of this. > > > Source/WebCore/page/SecurityOrigin.cpp:105 > > + && !url.protocolIs("gopher") > > GOPHER! It's in the spec.
Build Bot
Comment 19 2016-09-20 09:50:22 PDT
Comment on attachment 289356 [details] Patch Attachment 289356 [details] did not pass mac-ews (mac): Output: http://webkit-queues.webkit.org/results/2113011 New failing tests: http/tests/security/postMessage/invalid-origin-throws-exception.html
Build Bot
Comment 20 2016-09-20 09:50:25 PDT
Created attachment 289362 [details] Archive of layout-test-results from ews103 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews103 Port: mac-yosemite Platform: Mac OS X 10.10.5
Build Bot
Comment 21 2016-09-20 09:59:26 PDT
Comment on attachment 289356 [details] Patch Attachment 289356 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/2113030 New failing tests: http/tests/security/postMessage/invalid-origin-throws-exception.html
Build Bot
Comment 22 2016-09-20 09:59:29 PDT
Created attachment 289366 [details] Archive of layout-test-results from ews107 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Build Bot
Comment 23 2016-09-20 10:04:11 PDT
Comment on attachment 289356 [details] Patch Attachment 289356 [details] did not pass mac-debug-ews (mac): Output: http://webkit-queues.webkit.org/results/2113027 New failing tests: http/tests/security/postMessage/invalid-origin-throws-exception.html
Build Bot
Comment 24 2016-09-20 10:04:14 PDT
Created attachment 289368 [details] Archive of layout-test-results from ews117 for mac-yosemite The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews117 Port: mac-yosemite Platform: Mac OS X 10.10.5
Build Bot
Comment 25 2016-09-20 10:11:22 PDT
Comment on attachment 289356 [details] Patch Attachment 289356 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/2113040 New failing tests: http/tests/security/postMessage/invalid-origin-throws-exception.html
Build Bot
Comment 26 2016-09-20 10:11:26 PDT
Created attachment 289370 [details] Archive of layout-test-results from ews123 for ios-simulator-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews123 Port: ios-simulator-elcapitan-wk2 Platform: Mac OS X 10.11.6
Alex Christensen
Comment 27 2016-09-20 10:59:30 PDT
Alex Christensen
Comment 28 2016-09-20 13:03:36 PDT
WebKit Commit Bot
Comment 29 2016-09-23 09:02:12 PDT
Re-opened since this is blocked by bug 162492
Alex Christensen
Comment 30 2016-09-23 09:21:11 PDT
Comment on attachment 289384 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=289384&action=review > Source/WebCore/page/SecurityOrigin.cpp:106 > + return !innerURL.protocolIsInHTTPFamily() > + && !innerURL.protocolIs("file") > + && !innerURL.protocolIs("ftp") > + && !innerURL.protocolIs("gopher") > + && !innerURL.protocolIs("ws") > + && !innerURL.protocolIs("wss"); When I reland this, I plan to add this: #if PLATFORM(GTK) // Comment explaining why this is needed... && !innerURL.protocolIs("resource") #endif
Carlos Garcia Campos
Comment 31 2016-09-27 04:35:05 PDT
(In reply to comment #30) > Comment on attachment 289384 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=289384&action=review > > > Source/WebCore/page/SecurityOrigin.cpp:106 > > + return !innerURL.protocolIsInHTTPFamily() > > + && !innerURL.protocolIs("file") > > + && !innerURL.protocolIs("ftp") > > + && !innerURL.protocolIs("gopher") > > + && !innerURL.protocolIs("ws") > > + && !innerURL.protocolIs("wss"); > > When I reland this, I plan to add this: > #if PLATFORM(GTK) > // Comment explaining why this is needed... > && !innerURL.protocolIs("resource") > #endif We would still need the new api to mark custom uri schemes as non-unique when registered.
Alex Christensen
Comment 32 2016-09-27 13:28:39 PDT
(In reply to comment #31) > (In reply to comment #30) > > Comment on attachment 289384 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=289384&action=review > > > > > Source/WebCore/page/SecurityOrigin.cpp:106 > > > + return !innerURL.protocolIsInHTTPFamily() > > > + && !innerURL.protocolIs("file") > > > + && !innerURL.protocolIs("ftp") > > > + && !innerURL.protocolIs("gopher") > > > + && !innerURL.protocolIs("ws") > > > + && !innerURL.protocolIs("wss"); > > > > When I reland this, I plan to add this: > > #if PLATFORM(GTK) > > // Comment explaining why this is needed... > > && !innerURL.protocolIs("resource") > > #endif > > We would still need the new api to mark custom uri schemes as non-unique > when registered. Yes, and I think that api should be automatically called when making a new GTK WebProcess or when opening the Web Inspector instead of putting this layering violation here.
Alex Christensen
Comment 33 2016-10-14 18:47:07 PDT
WebKit Commit Bot
Comment 34 2016-10-14 18:48:22 PDT
Attachment 291698 [details] did not pass style-queue: ERROR: Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h:0: Use #pragma once header guard. [build/header_guard] [5] ERROR: Source/WebKit/mac/WebView/WebViewPrivate.h:0: Use #pragma once header guard. [build/header_guard] [5] Total errors found: 2 in 34 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alex Christensen
Comment 35 2016-10-14 18:50:03 PDT
Carlos or Michael, could you deprecate the old GTK API and add new GTK API like I tried to do in https://bugs.webkit.org/show_bug.cgi?id=162475 and use it to register the "resource" scheme when opening the web inspector so we don't have another https://bugs.webkit.org/show_bug.cgi?id=162387 ?
Carlos Garcia Campos
Comment 36 2016-10-15 01:55:29 PDT
(In reply to comment #35) > Carlos or Michael, could you deprecate the old GTK API and add new GTK API > like I tried to do in https://bugs.webkit.org/show_bug.cgi?id=162475 and use > it to register the "resource" scheme when opening the web inspector so we > don't have another https://bugs.webkit.org/show_bug.cgi?id=162387 ? Yes, I'll do it, but to not break anything until I write the patch, could you please do a couple of things? 1- In Source/WebKit2/UIProcess/API/gtk/WebKitSecurityManager.cpp remove the uses of removed API from registerSecurityPolicyForURIScheme() and checkSecurityPolicyForURIScheme() just to fix the build. Do nothing when registering, and return false when checking, adding a FIXME in both cases. 2- In SchemeRegistry.cpp add "resource" unconditionally to schemesForNonNullOrigins map inside a #if USE(SOUP) block. No need for FIXME here, we always want this. Maybe that still breaks a unit tests, but that's not a problem. At least it will build and the inspector will be usable.
Darin Adler
Comment 37 2016-10-15 15:56:08 PDT
Comment on attachment 291698 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=291698&action=review I’d like someone else, Anders maybe, to review the new SPI parts of this. I reviewed the rest. > Source/WebCore/page/SecurityOrigin.cpp:107 > + if (innerURL.protocolIsInHTTPFamily() > + || innerURL.protocolIs("file") > + || innerURL.protocolIs("ftp") > + || innerURL.protocolIs("gopher") > + || innerURL.protocolIs("ws") > + || innerURL.protocolIs("wss")) Do we have this list anywhere else? I would have expected isSpecialProtocol instead of this list written out like this. > Source/WebCore/platform/SchemeRegistry.cpp:77 > +static URLSchemesMap& schemesForNonNullOrigins() Why call this NonNullOrigins when the code below calls it "TupleSecurityOrigin"? > Source/WebCore/platform/SchemeRegistry.h:52 > - WEBCORE_EXPORT static void registerURLSchemeAsNoAccess(const String&); > - static bool shouldTreatURLSchemeAsNoAccess(const String&); > + WEBCORE_EXPORT static void registerURLSchemeForTupleSecurityOrigin(const String&); > + static bool schemeShouldReceiveTupleSecurityOrigin(const String&); GTK port was using this, needs to be fixed. > LayoutTests/http/tests/security/postMessage/invalid-origin-throws-exception.html:32 > + // URLs without an origin should fail witha syntax error. Missing space between "with" and "a".
Alex Christensen
Comment 38 2016-10-15 19:00:51 PDT
(In reply to comment #37) > Comment on attachment 291698 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=291698&action=review > > I’d like someone else, Anders maybe, to review the new SPI parts of this. I > reviewed the rest. Anders said SchemeRegistry should be per Page instead of global. Then we could put this new API on WKWebView. I'm not sure if we can get away with a change like this without doing that. > > > Source/WebCore/page/SecurityOrigin.cpp:107 > > + if (innerURL.protocolIsInHTTPFamily() > > + || innerURL.protocolIs("file") > > + || innerURL.protocolIs("ftp") > > + || innerURL.protocolIs("gopher") > > + || innerURL.protocolIs("ws") > > + || innerURL.protocolIs("wss")) > > Do we have this list anywhere else? I would have expected isSpecialProtocol > instead of this list written out like this. We do! We should make URL::protocol return a StringView then use the same scheme function from URLParser.cpp. > > > Source/WebCore/platform/SchemeRegistry.cpp:77 > > +static URLSchemesMap& schemesForNonNullOrigins() > > Why call this NonNullOrigins when the code below calls it > "TupleSecurityOrigin"? Oh, this was from before I decided on a name. I decided on "tuple" based on the spec, but I'm not sure if that's a good name. > > > Source/WebCore/platform/SchemeRegistry.h:52 > > - WEBCORE_EXPORT static void registerURLSchemeAsNoAccess(const String&); > > - static bool shouldTreatURLSchemeAsNoAccess(const String&); > > + WEBCORE_EXPORT static void registerURLSchemeForTupleSecurityOrigin(const String&); > > + static bool schemeShouldReceiveTupleSecurityOrigin(const String&); > > GTK port was using this, needs to be fixed. > > > LayoutTests/http/tests/security/postMessage/invalid-origin-throws-exception.html:32 > > + // URLs without an origin should fail witha syntax error. > > Missing space between "with" and "a".
Alex Christensen
Comment 39 2020-11-06 10:32:44 PST
Alex Christensen
Comment 40 2020-11-06 11:33:59 PST
Comment on attachment 413444 [details] Patch Looks like I do need to organize this per-page and inform the network process by adding to NetworkSchemeRegistry
Alex Christensen
Comment 41 2020-11-06 12:05:26 PST
Just kidding. I need to add blob to the list according to https://url.spec.whatwg.org/#origin
Alex Christensen
Comment 42 2020-11-06 12:07:55 PST
Alex Christensen
Comment 43 2020-11-06 13:19:19 PST
Alex Christensen
Comment 44 2020-11-06 19:35:39 PST
Alex Christensen
Comment 45 2020-11-10 07:51:25 PST
Alex Christensen
Comment 46 2020-11-10 12:09:09 PST
Devin Rousso
Comment 47 2020-11-10 12:51:27 PST
Comment on attachment 413721 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=413721&action=review > LayoutTests/inspector/unit-tests/url-utilities.html:202 > - origin: "app-specific://example.com", > + origin: "null", I think this will modify the behavior of Web Inspector. Web Inspector should always show the origin of URLs. As-is, I think this change would cause all custom-origin URLs to be shown at the top-level of the navigation sidebar in the Sources Tab instead of being organized underneath a tree element for that custom-origin. This would likely require minor adjustments to `parseURL` in `Source/WebInspectorUI/UserInterface/Base/URLUtilities.js`.
Alex Christensen
Comment 48 2020-11-10 13:11:32 PST
Devin, could you look into what problems that would cause? I made it so if there are WKURLSchemeHandlers registered, it allows non-null origins. I believe that should prevent such problems in practice. If someone has a URL with an unrecognized scheme that has no scheme handler, then the origin should change to become null. I'm open to learning what problems that may cause.
Devin Rousso
Comment 49 2020-11-10 13:34:33 PST
Created attachment 413731 [details] [Image] screenshot of current behavior of custom origin in Web Inspector (In reply to Alex Christensen from comment #48) > Devin, could you look into what problems that would cause? I made it so if there are WKURLSchemeHandlers registered, it allows non-null origins. I believe that should prevent such problems in practice. If someone has a URL with an unrecognized scheme that has no scheme handler, then the origin should change to become null. I'm open to learning what problems that may cause. Attached an example screenshot of what a custom origin looks like right now in Web Inspector. You can reproduce this yourself by 1. inspecting <https://webkit.org/> 2. switching to "By Path" in the Sources Tab 3. evaluating `(new Image).src = "app-specific://example.com"` in the Web Inspector console If the `origin` of the object returned by `parseURL` is `null`, then I think that would instead appear at the top-level instead of nested underneath a tree element for "app-specific://example.com". FWIW, I'm not sure how often this will actually happen and/or be an issue, because as you said this only affects custom origins that do not have a scheme handler. And even then, I think the only problem it would cause is that the resource is not placed in the same spot it was before. It may be worth leaving the test as-is and just changing the expected file to `FAIL` with a followup bug for adjusting Web Inspector so that it can still recognize the origin.
Alex Christensen
Comment 50 2020-11-10 13:39:23 PST
I think that's an intentional change in behavior, and I don't think any followup is necessary with the web inspector. I think the test correctly reflects that if you need the origin of an unrecognized scheme it will now be null. I have added an API test that verifies that if a scheme handler is registered in the app, the origin will continue to be non-null. If you feel strongly that I should leave the inspector test as failing and file another bug I will, but I don't think it's necessary.
Devin Rousso
Comment 51 2020-11-10 13:45:43 PST
(In reply to Alex Christensen from comment #50) > I think that's an intentional change in behavior, and I don't think any followup is necessary with the web inspector. I think the test correctly reflects that if you need the origin of an unrecognized scheme it will now be null. I agree that as far as JavaScript is concerned, this is an intentional change in behavior, but for the purposes of Web Inspector as a developer tool, we should always show the origin even when it's hidden from JavaScript. As an example, if a page tries to load `a://example.com/foo.js` and `b://example.com/foo.js`, they should not appear under the same top-level item when "By Path". Web Inspector intentionally displays data that is hidden from JavaScript/native APIs all the time, as that's one of the reasons why it exists in the first place. > I have added an API test that verifies that if a scheme handler is registered in the app, the origin will continue to be non-null. Awesome! That's I think why this is likely to be an extremely rare issue in production. > If you feel strongly that I should leave the inspector test as failing and file another bug I will, but I don't think it's necessary. Eh, I don't have a strong opinion one way or the other how you leave the test, but I do think this warrants a followup bug (and maybe a FIXME comment in the test) to ensure that this change in behavior does not negatively affect Web Inspector. Maybe something like "Web Inspector: ensure that `parseURL` is able to derive an origin for non-registered schemes"?
Alex Christensen
Comment 52 2020-11-10 13:48:11 PST
The whole point of this is that neither Web Inspector nor web content should be able to derive an origin for non-registered schemes. Only registered schemes should be able to be an origin.
Devin Rousso
Comment 53 2020-11-10 14:10:54 PST
(In reply to Alex Christensen from comment #52) > The whole point of this is that neither Web Inspector nor web content should be able to derive an origin for non-registered schemes. Only registered schemes should be able to be an origin. To clarify something, I'm not suggesting that you modify `URL` when in Web Inspector to allow the `origin` for non-registered schemes. Web Inspector should not be given any special functionality unless absolutely necessary. I'm suggesting that the `parseURL` function that Web Inspector has defined be modified to derive the origin on its own. I agree that as far as the JavaScript `URL` is concerned, the origin should not be shown for non-registered schemes. The purpose of Web Inspector is to expose information to the developer that aids them in introspecting/debugging their web content. This often takes the form of exposing information that is not normally available via web APIs. If a developer has written code for `app-specific://example.com`, Web Inspector should show the information as it was actually used in the engine. Also, even with your patch I believe Web Inspector will still show the custom scheme in other places like the table in the Network Tab (right click on the header and check Scheme). Those places follow different code paths, so they are likely unaffected by your changes to `URL`. I'm just asking that Web Inspector be consistent in what information it shows regardless of where it gets the data (which usually involves Web Inspector doing extra work on top of what is exposed via web APIs, which is one of the reasons why the Web Inspector protocol exists). And to be clear, this is not something that needs to be changed in WebCore/WebKit/etc., it's purely something that Web Inspector will need to do on its own (`parseURL` inside `Source/WebInspectorUI/UserInterface/Base/URLUtilities.js`).
Alex Christensen
Comment 54 2020-11-10 16:24:32 PST
Alex Christensen
Comment 55 2020-11-12 09:11:40 PST
Alex Christensen
Comment 56 2020-11-12 09:26:23 PST
Comment on attachment 413940 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=413940&action=review > Source/WebInspectorUI/UserInterface/Base/URLUtilities.js:136 > + if (parsed.origin && parsed.origin != "null") I did this tweak to parseURL instead, which preserves the WebInspector behavior.
Devin Rousso
Comment 57 2020-11-12 09:54:33 PST
Comment on attachment 413940 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=413940&action=review >> Source/WebInspectorUI/UserInterface/Base/URLUtilities.js:136 >> + if (parsed.origin && parsed.origin != "null") > > I did this tweak to parseURL instead, which preserves the WebInspector behavior. NIT: this should be `!==` Thanks for fixing this! :)
Alex Christensen
Comment 58 2020-11-12 15:12:30 PST
(In reply to Devin Rousso from comment #57) > NIT: this should be `!==` Will tweak when landing.
Geoffrey Garen
Comment 59 2021-02-03 13:20:50 PST
Comment on attachment 413940 [details] Patch r=me with the !== change
Alex Christensen
Comment 60 2021-02-06 20:56:45 PST
EWS
Comment 61 2021-02-06 22:02:41 PST
Committed r272469: <https://commits.webkit.org/r272469> All reviewed patches have been landed. Closing bug and clearing flags on attachment 419525 [details].
Radar WebKit Bug Importer
Comment 62 2021-02-06 22:03:16 PST
Michael Catanzaro
Comment 63 2021-03-06 13:18:50 PST
Hm, I think this caused Epiphany to crash when attempting to download any PDF. webkit_security_origin_new_for_uri() returns NULL for ephy-pdf: URIs, but the return value is not nullable, so Epiphany correctly dereferences it and crashes. """ In order to allow things like web extensions to continue to work, we allow non-null origins for schemes for which a WKURLSchemeHandler has been registered. We learned this lesson 4 years ago when we tried this change. This also makes sense conceptually because those schemes will be handled by the containing application, so they can be an "origin" for a page. """ That sounds good to me, Epiphany registers ephy-pdf: using webkit_web_context_register_uri_scheme(), so in theory it ought to work, but it doesn't. I'll look closer on Monday.
Michael Catanzaro
Comment 64 2021-03-08 15:08:44 PST
Note You need to log in before you can comment on or make changes to this bug.