|
|
|
Lines 457-489
nsFrameLoader::ReallyStartLoadingInterna
|
Link Here
|
|---|
|
| 457 |
// Just to be safe, recheck uri. |
457 |
// Just to be safe, recheck uri. |
| 458 |
rv = CheckURILoad(mURIToLoad); |
458 |
rv = CheckURILoad(mURIToLoad); |
| 459 |
NS_ENSURE_SUCCESS(rv, rv); |
459 |
NS_ENSURE_SUCCESS(rv, rv); |
| 460 |
|
460 |
|
| 461 |
nsCOMPtr<nsIDocShellLoadInfo> loadInfo; |
461 |
nsCOMPtr<nsIDocShellLoadInfo> loadInfo; |
| 462 |
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo)); |
462 |
mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo)); |
| 463 |
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE); |
463 |
NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE); |
| 464 |
|
464 |
|
| 465 |
// Does this frame have a parent which is already sandboxed or is this |
|
|
| 466 |
// an <iframe> with a sandbox attribute? |
| 467 |
uint32_t sandboxFlags = 0; |
| 468 |
uint32_t parentSandboxFlags = mOwnerContent->OwnerDoc()->GetSandboxFlags(); |
| 469 |
|
| 470 |
HTMLIFrameElement* iframe = HTMLIFrameElement::FromContent(mOwnerContent); |
| 471 |
|
| 472 |
if (iframe) { |
| 473 |
sandboxFlags = iframe->GetSandboxFlags(); |
| 474 |
} |
| 475 |
|
| 476 |
if (sandboxFlags || parentSandboxFlags) { |
| 477 |
// The child can only add restrictions, never remove them. |
| 478 |
sandboxFlags |= parentSandboxFlags; |
| 479 |
mDocShell->SetSandboxFlags(sandboxFlags); |
| 480 |
} |
| 481 |
|
| 482 |
// If this frame is sandboxed with respect to origin we will set it up with |
465 |
// If this frame is sandboxed with respect to origin we will set it up with |
| 483 |
// a null principal later in nsDocShell::DoURILoad. |
466 |
// a null principal later in nsDocShell::DoURILoad. |
| 484 |
// We do it there to correctly sandbox content that was loaded into |
467 |
// We do it there to correctly sandbox content that was loaded into |
| 485 |
// the frame via other methods than the src attribute. |
468 |
// the frame via other methods than the src attribute. |
| 486 |
// We'll use our principal, not that of the document loaded inside us. This |
469 |
// We'll use our principal, not that of the document loaded inside us. This |
| 487 |
// is very important; needed to prevent XSS attacks on documents loaded in |
470 |
// is very important; needed to prevent XSS attacks on documents loaded in |
| 488 |
// subframes! |
471 |
// subframes! |
| 489 |
loadInfo->SetOwner(mOwnerContent->NodePrincipal()); |
472 |
loadInfo->SetOwner(mOwnerContent->NodePrincipal()); |
|
Lines 1564-1579
nsFrameLoader::MaybeCreateDocShell()
|
Link Here
|
|---|
|
| 1564 |
doc->GetContainer(); |
1547 |
doc->GetContainer(); |
| 1565 |
nsCOMPtr<nsIWebNavigation> parentAsWebNav = do_QueryInterface(container); |
1548 |
nsCOMPtr<nsIWebNavigation> parentAsWebNav = do_QueryInterface(container); |
| 1566 |
NS_ENSURE_STATE(parentAsWebNav); |
1549 |
NS_ENSURE_STATE(parentAsWebNav); |
| 1567 |
|
1550 |
|
| 1568 |
// Create the docshell... |
1551 |
// Create the docshell... |
| 1569 |
mDocShell = do_CreateInstance("@mozilla.org/docshell;1"); |
1552 |
mDocShell = do_CreateInstance("@mozilla.org/docshell;1"); |
| 1570 |
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); |
1553 |
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); |
| 1571 |
|
1554 |
|
|
|
1555 |
// Apply sandbox flags even if our owner is not an iframe, as this copies |
| 1556 |
// flags from our owning content's owning document. |
| 1557 |
uint32_t sandboxFlags = 0; |
| 1558 |
HTMLIFrameElement* iframe = HTMLIFrameElement::FromContent(mOwnerContent); |
| 1559 |
if (iframe) { |
| 1560 |
sandboxFlags = iframe->GetSandboxFlags(); |
| 1561 |
} |
| 1562 |
ApplySandboxFlags(sandboxFlags); |
| 1563 |
|
| 1572 |
if (!mNetworkCreated) { |
1564 |
if (!mNetworkCreated) { |
| 1573 |
if (mDocShell) { |
1565 |
if (mDocShell) { |
| 1574 |
mDocShell->SetCreatedDynamically(true); |
1566 |
mDocShell->SetCreatedDynamically(true); |
| 1575 |
} |
1567 |
} |
| 1576 |
} |
1568 |
} |
| 1577 |
|
1569 |
|
| 1578 |
// Get the frame name and tell the docshell about it. |
1570 |
// Get the frame name and tell the docshell about it. |
| 1579 |
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); |
1571 |
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); |
|
Lines 2463-2478
nsFrameLoader::SetDetachedSubdocView(nsV
|
Link Here
|
|---|
|
| 2463 |
|
2455 |
|
| 2464 |
nsView* |
2456 |
nsView* |
| 2465 |
nsFrameLoader::GetDetachedSubdocView(nsIDocument** aContainerDoc) const |
2457 |
nsFrameLoader::GetDetachedSubdocView(nsIDocument** aContainerDoc) const |
| 2466 |
{ |
2458 |
{ |
| 2467 |
NS_IF_ADDREF(*aContainerDoc = mContainerDocWhileDetached); |
2459 |
NS_IF_ADDREF(*aContainerDoc = mContainerDocWhileDetached); |
| 2468 |
return mDetachedSubdocViews; |
2460 |
return mDetachedSubdocViews; |
| 2469 |
} |
2461 |
} |
| 2470 |
|
2462 |
|
|
|
2463 |
void |
| 2464 |
nsFrameLoader::ApplySandboxFlags(uint32_t sandboxFlags) { |
| 2465 |
if (mDocShell) { |
| 2466 |
uint32_t parentSandboxFlags = mOwnerContent->OwnerDoc()->GetSandboxFlags(); |
| 2467 |
|
| 2468 |
// The child can only add restrictions, never remove them. |
| 2469 |
sandboxFlags |= parentSandboxFlags; |
| 2470 |
mDocShell->SetSandboxFlags(sandboxFlags); |
| 2471 |
} |
| 2472 |
} |
| 2473 |
|
| 2471 |
/* virtual */ void |
2474 |
/* virtual */ void |
| 2472 |
nsFrameLoader::AttributeChanged(nsIDocument* aDocument, |
2475 |
nsFrameLoader::AttributeChanged(nsIDocument* aDocument, |
| 2473 |
mozilla::dom::Element* aElement, |
2476 |
mozilla::dom::Element* aElement, |
| 2474 |
int32_t aNameSpaceID, |
2477 |
int32_t aNameSpaceID, |
| 2475 |
nsIAtom* aAttribute, |
2478 |
nsIAtom* aAttribute, |
| 2476 |
int32_t aModType) |
2479 |
int32_t aModType) |
| 2477 |
{ |
2480 |
{ |
| 2478 |
MOZ_ASSERT(mObservingOwnerContent); |
2481 |
MOZ_ASSERT(mObservingOwnerContent); |