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/frame/LocalDOMWindow.cpp

Issue 1374533002: Null out LocalDOMWindow::m_frame on navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try to fix crash-on-querying-event-path.html Created 5 years, 2 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) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 m_properties.add(property); 516 m_properties.add(property);
517 } 517 }
518 518
519 void LocalDOMWindow::unregisterProperty(DOMWindowProperty* property) 519 void LocalDOMWindow::unregisterProperty(DOMWindowProperty* property)
520 { 520 {
521 m_properties.remove(property); 521 m_properties.remove(property);
522 } 522 }
523 523
524 void LocalDOMWindow::reset() 524 void LocalDOMWindow::reset()
525 { 525 {
526 frameDestroyed(); 526 m_frameObserver->contextDestroyed();
527 527
528 m_screen = nullptr; 528 m_screen = nullptr;
529 m_history = nullptr; 529 m_history = nullptr;
530 m_locationbar = nullptr; 530 m_locationbar = nullptr;
531 m_menubar = nullptr; 531 m_menubar = nullptr;
532 m_personalbar = nullptr; 532 m_personalbar = nullptr;
533 m_scrollbars = nullptr; 533 m_scrollbars = nullptr;
534 m_statusbar = nullptr; 534 m_statusbar = nullptr;
535 m_toolbar = nullptr; 535 m_toolbar = nullptr;
536 m_console = nullptr; 536 m_console = nullptr;
537 m_navigator = nullptr; 537 m_navigator = nullptr;
538 m_media = nullptr; 538 m_media = nullptr;
539 m_applicationCache = nullptr; 539 m_applicationCache = nullptr;
540 #if ENABLE(ASSERT) 540 #if ENABLE(ASSERT)
541 m_hasBeenReset = true; 541 m_hasBeenReset = true;
542 #endif 542 #endif
543 543
544 resetLocation();
545
546 LocalDOMWindow::notifyContextDestroyed(); 544 LocalDOMWindow::notifyContextDestroyed();
547 } 545 }
548 546
549 void LocalDOMWindow::sendOrientationChangeEvent() 547 void LocalDOMWindow::sendOrientationChangeEvent()
550 { 548 {
551 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); 549 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled());
552 ASSERT(frame()->isMainFrame()); 550 ASSERT(frame()->isMainFrame());
553 551
554 // Before dispatching the event, build a list of all frames in the page 552 // Before dispatching the event, build a list of all frames in the page
555 // to send the event to, to mitigate side effects from event handlers 553 // to send the event to, to mitigate side effects from event handlers
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 { 653 {
656 if (!isCurrentlyDisplayedInFrame()) 654 if (!isCurrentlyDisplayedInFrame())
657 return nullptr; 655 return nullptr;
658 if (!m_applicationCache) 656 if (!m_applicationCache)
659 m_applicationCache = ApplicationCache::create(frame()); 657 m_applicationCache = ApplicationCache::create(frame());
660 return m_applicationCache.get(); 658 return m_applicationCache.get();
661 } 659 }
662 660
663 Navigator* LocalDOMWindow::navigator() const 661 Navigator* LocalDOMWindow::navigator() const
664 { 662 {
665 if (!isCurrentlyDisplayedInFrame() && (!m_navigator || m_navigator->frame()) ) {
666 // We return a navigator with null frame instead of returning null
667 // pointer as other functions do, in order to allow users to access
668 // functions such as navigator.product.
669 m_navigator = Navigator::create(nullptr);
670 }
671 if (!m_navigator) 663 if (!m_navigator)
672 m_navigator = Navigator::create(frame()); 664 m_navigator = Navigator::create(frame());
673 // As described above, when not dispayed in the frame, the returning
674 // navigator should not be associated with the frame.
675 ASSERT(isCurrentlyDisplayedInFrame() || !m_navigator->frame());
676 return m_navigator.get(); 665 return m_navigator.get();
677 } 666 }
678 667
679 void LocalDOMWindow::schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent> ev ent, LocalDOMWindow* source, SecurityOrigin* target, PassRefPtrWillBeRawPtr<Scri ptCallStack> stackTrace) 668 void LocalDOMWindow::schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent> ev ent, LocalDOMWindow* source, SecurityOrigin* target, PassRefPtrWillBeRawPtr<Scri ptCallStack> stackTrace)
680 { 669 {
681 // Schedule the message. 670 // Schedule the message.
682 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current Token())); 671 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current Token()));
683 timer->startOneShot(0, FROM_HERE); 672 timer->startOneShot(0, FROM_HERE);
684 timer->suspendIfNeeded(); 673 timer->suspendIfNeeded();
685 m_postMessageTimers.add(timer.release()); 674 m_postMessageTimers.add(timer.release());
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 { 1369 {
1381 RefPtrWillBeRawPtr<Event> loadEvent(Event::create(EventTypeNames::load)); 1370 RefPtrWillBeRawPtr<Event> loadEvent(Event::create(EventTypeNames::load));
1382 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) { 1371 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) {
1383 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching 1372 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching
1384 // the event, so protect it to prevent writing the end time into freed m emory. 1373 // the event, so protect it to prevent writing the end time into freed m emory.
1385 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = frame()->loader().do cumentLoader(); 1374 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = frame()->loader().do cumentLoader();
1386 DocumentLoadTiming& timing = documentLoader->timing(); 1375 DocumentLoadTiming& timing = documentLoader->timing();
1387 timing.markLoadEventStart(); 1376 timing.markLoadEventStart();
1388 dispatchEvent(loadEvent, document()); 1377 dispatchEvent(loadEvent, document());
1389 timing.markLoadEventEnd(); 1378 timing.markLoadEventEnd();
1390 } else 1379 } else {
1391 dispatchEvent(loadEvent, document()); 1380 dispatchEvent(loadEvent, document());
1381 }
1392 1382
1393 // For load events, send a separate load event to the enclosing frame only. 1383 // For load events, send a separate load event to the enclosing frame only.
1394 // This is a DOM extension and is independent of bubbling/capturing rules of 1384 // This is a DOM extension and is independent of bubbling/capturing rules of
1395 // the DOM. 1385 // the DOM.
1396 FrameOwner* owner = frame() ? frame()->owner() : nullptr; 1386 FrameOwner* owner = frame() ? frame()->owner() : nullptr;
1397 if (owner) 1387 if (owner)
1398 owner->dispatchLoad(); 1388 owner->dispatchLoad();
1399 1389
1400 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkLoad", TRACE_EVENT_SCOPE_THRE AD, "data", InspectorMarkLoadEvent::data(frame())); 1390 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkLoad", TRACE_EVENT_SCOPE_THRE AD, "data", InspectorMarkLoadEvent::data(frame()));
1401 InspectorInstrumentation::loadEventFired(frame()); 1391 InspectorInstrumentation::loadEventFired(frame());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 if (!enteredWindow->allowPopUp()) { 1457 if (!enteredWindow->allowPopUp()) {
1468 // Because FrameTree::find() returns true for empty strings, we must che ck for empty frame names. 1458 // Because FrameTree::find() returns true for empty strings, we must che ck for empty frame names.
1469 // Otherwise, illegitimate window.open() calls with no name will pass ri ght through the popup blocker. 1459 // Otherwise, illegitimate window.open() calls with no name will pass ri ght through the popup blocker.
1470 if (frameName.isEmpty() || !frame()->tree().find(frameName)) 1460 if (frameName.isEmpty() || !frame()->tree().find(frameName))
1471 return nullptr; 1461 return nullptr;
1472 } 1462 }
1473 1463
1474 // Get the target frame for the special cases of _top and _parent. 1464 // Get the target frame for the special cases of _top and _parent.
1475 // In those cases, we schedule a location change right now and return early. 1465 // In those cases, we schedule a location change right now and return early.
1476 Frame* targetFrame = nullptr; 1466 Frame* targetFrame = nullptr;
1477 if (frameName == "_top") 1467 if (frameName == "_top") {
1478 targetFrame = frame()->tree().top(); 1468 targetFrame = frame()->tree().top();
1479 else if (frameName == "_parent") { 1469 } else if (frameName == "_parent") {
1480 if (Frame* parent = frame()->tree().parent()) 1470 if (Frame* parent = frame()->tree().parent())
1481 targetFrame = parent; 1471 targetFrame = parent;
1482 else 1472 else
1483 targetFrame = frame(); 1473 targetFrame = frame();
1484 } 1474 }
1485 1475
1486 if (targetFrame) { 1476 if (targetFrame) {
1487 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*t argetFrame)) 1477 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*t argetFrame))
1488 return nullptr; 1478 return nullptr;
1489 1479
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 visitor->trace(m_eventQueue); 1513 visitor->trace(m_eventQueue);
1524 visitor->trace(m_postMessageTimers); 1514 visitor->trace(m_postMessageTimers);
1525 HeapSupplementable<LocalDOMWindow>::trace(visitor); 1515 HeapSupplementable<LocalDOMWindow>::trace(visitor);
1526 #endif 1516 #endif
1527 DOMWindow::trace(visitor); 1517 DOMWindow::trace(visitor);
1528 DOMWindowLifecycleNotifier::trace(visitor); 1518 DOMWindowLifecycleNotifier::trace(visitor);
1529 } 1519 }
1530 1520
1531 LocalFrame* LocalDOMWindow::frame() const 1521 LocalFrame* LocalDOMWindow::frame() const
1532 { 1522 {
1523 // If the LocalDOMWindow still has a frame reference, that frame must point
1524 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation
1525 // where script execution leaks between different LocalDOMWindows.
1526 if (m_frameObserver->frame())
1527 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this);
1533 return m_frameObserver->frame(); 1528 return m_frameObserver->frame();
1534 } 1529 }
1535 1530
1536 } // namespace blink 1531 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698