Changeset 228036 in webkit
- Timestamp:
- Feb 2, 2018 4:49:56 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228034 r228036 1 2018-02-02 David Quesada <david_quesada@apple.com> 2 3 WebAppManifest scope should default to the containing directory of start_url if 'scope' is not specified 4 https://bugs.webkit.org/show_bug.cgi?id=182363 5 rdar://problem/37093498 6 7 Reviewed by Ryosuke Niwa. 8 9 If an app manifest doesn't specify a scope, we should default to the "parent directory" of 10 the start URL, rather than leaving the app unbounded. This is more reasonable than using the 11 entire internet as the app scope. 12 13 No new tests, updates to the existing tests verify the new behavior. 14 15 * Modules/applicationmanifest/ApplicationManifestParser.cpp: 16 (WebCore::ApplicationManifestParser::parseScope): 17 1 18 2018-02-02 Youenn Fablet <youenn@apple.com> 2 19 -
trunk/Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp
r225639 r228036 194 194 URL ApplicationManifestParser::parseScope(const JSON::Object& manifest, const URL& documentURL, const URL& startURL) 195 195 { 196 URL defaultScope { startURL, "./" }; 197 196 198 RefPtr<JSON::Value> value; 197 199 if (!manifest.getValue("scope", value)) 198 return { };200 return defaultScope; 199 201 200 202 String stringValue; 201 203 if (!value->asString(stringValue)) { 202 204 logManifestPropertyNotAString(ASCIILiteral("scope")); 203 return { };205 return defaultScope; 204 206 } 205 207 206 208 if (stringValue.isEmpty()) 207 return { };209 return defaultScope; 208 210 209 211 URL scopeURL(m_manifestURL, stringValue); 210 212 if (!scopeURL.isValid()) { 211 213 logManifestPropertyInvalidURL(ASCIILiteral("scope")); 212 return { };214 return defaultScope; 213 215 } 214 216 … … 217 219 auto documentOrigin = SecurityOrigin::create(documentURL); 218 220 logDeveloperWarning(ASCIILiteral("The scope's origin of \"") + scopeURLOrigin->toString() + ASCIILiteral("\" is different from the document's origin of \"") + documentOrigin->toString() + ASCIILiteral("\".")); 219 return { };221 return defaultScope; 220 222 } 221 223 222 224 if (!isInScope(scopeURL, startURL)) { 223 225 logDeveloperWarning(ASCIILiteral("The start URL is not within scope of the provided scope URL.")); 224 return { };226 return defaultScope; 225 227 } 226 228 -
trunk/Tools/ChangeLog
r228025 r228036 1 2018-02-02 David Quesada <david_quesada@apple.com> 2 3 WebAppManifest scope should default to the containing directory of start_url if 'scope' is not specified 4 https://bugs.webkit.org/show_bug.cgi?id=182363 5 rdar://problem/37093498 6 7 Reviewed by Ryosuke Niwa. 8 9 Updated ApplicationManifestParserTests to account for the new default scope behavior. 10 11 * TestWebKitAPI/Tests/WebCore/ApplicationManifestParser.cpp: 12 (assertManifestHasDefaultValues): 13 (TEST_F): 14 1 15 2018-02-02 Youenn Fablet <youenn@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/ApplicationManifestParser.cpp
r225699 r228036 136 136 EXPECT_TRUE(manifest.shortName.isNull()); 137 137 EXPECT_TRUE(manifest.description.isNull()); 138 EXPECT_ TRUE(manifest.scope.isEmpty());139 EXPECT_STREQ( manifest.startURL.string().utf8().data(), documentURL.string().utf8().data());138 EXPECT_STREQ("https://example.com/", manifest.scope.string().utf8().data()); 139 EXPECT_STREQ(documentURL.string().utf8().data(), manifest.startURL.string().utf8().data()); 140 140 } 141 141 … … 248 248 TEST_F(ApplicationManifestParserTest, Scope) 249 249 { 250 testScope("123", String()); 251 testScope("null", String()); 252 testScope("true", String()); 253 testScope("{ }", String()); 254 testScope("[ ]", String()); 255 testScope("\"\"", String()); 256 257 testScope("\"http:?\"", String()); 258 259 // If scope URL is not same origin as document URL, return undefined. 250 // If the scope is not a string or not a valid URL, return the default scope (the parent path of the start URL). 251 m_documentURL = { { }, "https://example.com/a/page?queryParam=value#fragment" }; 252 m_manifestURL = { { }, "https://example.com/manifest.json" }; 253 testScope("123", "https://example.com/a/"); 254 testScope("null", "https://example.com/a/"); 255 testScope("true", "https://example.com/a/"); 256 testScope("{ }", "https://example.com/a/"); 257 testScope("[ ]", "https://example.com/a/"); 258 testScope("\"\"", "https://example.com/a/"); 259 testScope("\"http:?\"", "https://example.com/a/"); 260 261 m_documentURL = { { }, "https://example.com/a/pageEndingWithSlash/" }; 262 testScope("null", "https://example.com/a/pageEndingWithSlash/"); 263 264 // If scope URL is not same origin as document URL, return the default scope. 260 265 m_documentURL = { { }, "https://example.com/home" }; 261 266 m_manifestURL = { { }, "https://other-site.com/manifest.json" }; 262 testScope("\"https://other-site.com/some-scope\"", String());267 testScope("\"https://other-site.com/some-scope\"", "https://example.com/"); 263 268 264 269 m_documentURL = { { }, "https://example.com/app/home" }; 265 270 m_manifestURL = { { }, "https://example.com/app/manifest.json" }; 266 271 267 // If start URL is not within scope of scope URL, return undefined268 testScope("\"https://example.com/subdirectory\"", String());272 // If start URL is not within scope of scope URL, return the default scope. 273 testScope("\"https://example.com/subdirectory\"", "https://example.com/app/"); 269 274 testScope("\"https://example.com/app\"", "https://example.com/app"); 270 testScope("\"https://example.com/APP\"", String());275 testScope("\"https://example.com/APP\"", "https://example.com/app/"); 271 276 testScope("\"https://example.com/a\"", "https://example.com/a"); 272 277
Note: See TracChangeset
for help on using the changeset viewer.