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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2009453002: service worker: Don't control a subframe of an insecure context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: consolidate tests Created 4 years, 6 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 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 return toLayoutPart(layoutObject)->widget(); 347 return toLayoutPart(layoutObject)->widget();
348 } 348 }
349 349
350 static bool acceptsEditingFocus(const Element& element) 350 static bool acceptsEditingFocus(const Element& element)
351 { 351 {
352 DCHECK(element.hasEditableStyle()); 352 DCHECK(element.hasEditableStyle());
353 353
354 return element.document().frame() && element.rootEditableElement(); 354 return element.document().frame() && element.rootEditableElement();
355 } 355 }
356 356
357 static bool isOriginPotentiallyTrustworthy(SecurityOrigin* origin, String* error Message)
358 {
359 if (origin->isPotentiallyTrustworthy())
360 return true;
361 if (errorMessage)
362 *errorMessage = origin->isPotentiallyTrustworthyErrorMessage();
363 return false;
364 }
365
366 uint64_t Document::s_globalTreeVersion = 0; 357 uint64_t Document::s_globalTreeVersion = 0;
367 358
368 static bool s_threadedParsingEnabledForTesting = true; 359 static bool s_threadedParsingEnabledForTesting = true;
369 360
370 using WeakDocumentSet = PersistentHeapHashSet<WeakMember<Document>>; 361 using WeakDocumentSet = PersistentHeapHashSet<WeakMember<Document>>;
371 362
372 static WeakDocumentSet& liveDocumentSet() 363 static WeakDocumentSet& liveDocumentSet()
373 { 364 {
374 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ()); 365 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ());
375 return set; 366 return set;
(...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after
3342 // Additionally, with 3333 // Additionally, with
3343 // <iframe src="scheme-has-exception://host"> 3334 // <iframe src="scheme-has-exception://host">
3344 // <iframe src="http://host"></iframe> 3335 // <iframe src="http://host"></iframe>
3345 // <iframe sandbox src="http://host"></iframe> 3336 // <iframe sandbox src="http://host"></iframe>
3346 // </iframe> 3337 // </iframe>
3347 // both inner iframes would fail the check, even though the outermost iframe 3338 // both inner iframes would fail the check, even though the outermost iframe
3348 // passes. 3339 // passes.
3349 // 3340 //
3350 // In all cases, a frame must be potentially trustworthy in addition to 3341 // In all cases, a frame must be potentially trustworthy in addition to
3351 // having an exception listed in order for the exception to be granted. 3342 // having an exception listed in order for the exception to be granted.
3352 if (!isOriginPotentiallyTrustworthy(getSecurityOrigin(), errorMessage)) 3343 if (!getSecurityOrigin()->isPotentiallyTrustworthy()) {
3344 if (errorMessage)
3345 *errorMessage = SecurityOrigin::isPotentiallyTrustworthyErrorMessage ();
3353 return false; 3346 return false;
3347 }
3354 3348
3355 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(getSecurityOrigin() ->protocol())) 3349 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(getSecurityOrigin() ->protocol()))
3356 return true; 3350 return true;
3357 3351
3358 if (privilegeContextCheck == StandardSecureContextCheck) { 3352 if (privilegeContextCheck == StandardSecureContextCheck) {
3359 if (!m_frame) 3353 Frame* parent = m_frame ? m_frame->tree().parent() : nullptr;
3360 return true; 3354 if (parent && !parent->canHaveSecureChild()) {
3361 Frame* parent = m_frame->tree().parent(); 3355 if (errorMessage)
3362 while (parent) { 3356 *errorMessage = SecurityOrigin::isPotentiallyTrustworthyErrorMes sage();
3363 if (!isOriginPotentiallyTrustworthy(parent->securityContext()->getSe curityOrigin(), errorMessage)) 3357 return false;
3364 return false;
3365 parent = parent->tree().parent();
3366 } 3358 }
3367 } 3359 }
3368 return true; 3360 return true;
3369 } 3361 }
3370 3362
3371 StyleSheetList& Document::styleSheets() 3363 StyleSheetList& Document::styleSheets()
3372 { 3364 {
3373 if (!m_styleSheetList) 3365 if (!m_styleSheetList)
3374 m_styleSheetList = StyleSheetList::create(this); 3366 m_styleSheetList = StyleSheetList::create(this);
3375 return *m_styleSheetList; 3367 return *m_styleSheetList;
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5999 #ifndef NDEBUG 5991 #ifndef NDEBUG
6000 using namespace blink; 5992 using namespace blink;
6001 void showLiveDocumentInstances() 5993 void showLiveDocumentInstances()
6002 { 5994 {
6003 WeakDocumentSet& set = liveDocumentSet(); 5995 WeakDocumentSet& set = liveDocumentSet();
6004 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5996 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6005 for (Document* document : set) 5997 for (Document* document : set)
6006 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 5998 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6007 } 5999 }
6008 #endif 6000 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698