Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: third_party/WebKit/Source/core/frame/SubresourceIntegrityTest.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/SubresourceIntegrity.h" 5 #include "core/frame/SubresourceIntegrity.h"
6 6
7 #include "core/HTMLNames.h" 7 #include "core/HTMLNames.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/html/HTMLScriptElement.h" 9 #include "core/html/HTMLScriptElement.h"
10 #include "platform/Crypto.h" 10 #include "platform/Crypto.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 expectParseFailure("not_really_a_valid_anything"); 290 expectParseFailure("not_really_a_valid_anything");
291 expectParseFailure("sha256-&&&foobar&&&"); 291 expectParseFailure("sha256-&&&foobar&&&");
292 expectParseFailure("sha256-\x01\x02\x03\x04"); 292 expectParseFailure("sha256-\x01\x02\x03\x04");
293 expectParseFailure("sha256-!!! sha256-!!!"); 293 expectParseFailure("sha256-!!! sha256-!!!");
294 294
295 expectEmptyParseResult("foobar:///sha256-abcdefg"); 295 expectEmptyParseResult("foobar:///sha256-abcdefg");
296 expectEmptyParseResult("ni://sha256-abcdefg"); 296 expectEmptyParseResult("ni://sha256-abcdefg");
297 expectEmptyParseResult("ni:///sha256-abcdefg"); 297 expectEmptyParseResult("ni:///sha256-abcdefg");
298 expectEmptyParseResult("notsha256atall-abcdefg"); 298 expectEmptyParseResult("notsha256atall-abcdefg");
299 299
300 expectParse("sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 300 expectParse(
301 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 301 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=",
302 HashAlgorithmSha256); 302 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
303 303
304 expectParse("sha-256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 304 expectParse(
305 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 305 "sha-256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=",
306 HashAlgorithmSha256); 306 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
307 307
308 expectParse(" sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE= ", 308 expectParse(
309 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 309 " sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE= ",
310 HashAlgorithmSha256); 310 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
311 311
312 expectParse( 312 expectParse(
313 "sha384-XVVXBGoYw6AJOh9J-Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup_tA1v5GPr", 313 "sha384-XVVXBGoYw6AJOh9J-Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup_tA1v5GPr",
314 "XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr", 314 "XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr",
315 HashAlgorithmSha384); 315 HashAlgorithmSha384);
316 316
317 expectParse( 317 expectParse(
318 "sha-384-XVVXBGoYw6AJOh9J_Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup_" 318 "sha-384-XVVXBGoYw6AJOh9J_Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup_"
319 "tA1v5GPr", 319 "tA1v5GPr",
320 "XVVXBGoYw6AJOh9J/Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr", 320 "XVVXBGoYw6AJOh9J/Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr",
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 407
408 const IntegrityMetadata invalidSha256AndValidSha256[] = { 408 const IntegrityMetadata invalidSha256AndValidSha256[] = {
409 IntegrityMetadata("BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 409 IntegrityMetadata("BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=",
410 HashAlgorithmSha256), 410 HashAlgorithmSha256),
411 }; 411 };
412 expectParseMultipleHashes( 412 expectParseMultipleHashes(
413 "sha256-!!! sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 413 "sha256-!!! sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=",
414 invalidSha256AndValidSha256, 414 invalidSha256AndValidSha256,
415 WTF_ARRAY_LENGTH(invalidSha256AndValidSha256)); 415 WTF_ARRAY_LENGTH(invalidSha256AndValidSha256));
416 416
417 expectParse("sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar", 417 expectParse(
418 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 418 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar",
419 HashAlgorithmSha256); 419 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
420 420
421 expectParse( 421 expectParse(
422 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?baz=foz", 422 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?baz=foz",
423 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256); 423 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
424 424
425 expectParse("sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?", 425 expectParse(
426 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 426 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?",
427 HashAlgorithmSha256); 427 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
428 expectParse("sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar", 428 expectParse(
429 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 429 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar",
430 HashAlgorithmSha256); 430 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
431 expectParse( 431 expectParse(
432 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?baz=foz", 432 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?baz=foz",
433 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256); 433 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
434 expectParse("sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo", 434 expectParse(
435 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 435 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo",
436 HashAlgorithmSha256); 436 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
437 expectParse("sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?", 437 expectParse(
438 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 438 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?",
439 HashAlgorithmSha256); 439 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
440 expectParse("sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo:bar", 440 expectParse(
441 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", 441 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo:bar",
442 HashAlgorithmSha256); 442 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256);
443 } 443 }
444 444
445 TEST_F(SubresourceIntegrityTest, ParsingBase64) { 445 TEST_F(SubresourceIntegrityTest, ParsingBase64) {
446 expectParse( 446 expectParse(
447 "sha384-XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr", 447 "sha384-XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr",
448 "XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr", 448 "XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr",
449 HashAlgorithmSha384); 449 HashAlgorithmSha384);
450 } 450 }
451 451
452 // 452 //
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 expectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript, 526 expectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript,
527 strlen(kBasicScript), secureURL, insecureURL); 527 strlen(kBasicScript), secureURL, insecureURL);
528 528
529 expectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript), 529 expectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript),
530 secureURL, insecureURL, NoCors); 530 secureURL, insecureURL, NoCors);
531 expectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript, 531 expectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript,
532 strlen(kBasicScript), secureURL, insecureURL); 532 strlen(kBasicScript), secureURL, insecureURL);
533 } 533 }
534 534
535 } // namespace blink 535 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/SmartClip.cpp ('k') | third_party/WebKit/Source/core/frame/VisualViewport.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698