OLD | NEW |
---|---|
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 m_properties.add(property); | 521 m_properties.add(property); |
522 } | 522 } |
523 | 523 |
524 void LocalDOMWindow::unregisterProperty(DOMWindowProperty* property) | 524 void LocalDOMWindow::unregisterProperty(DOMWindowProperty* property) |
525 { | 525 { |
526 m_properties.remove(property); | 526 m_properties.remove(property); |
527 } | 527 } |
528 | 528 |
529 void LocalDOMWindow::reset() | 529 void LocalDOMWindow::reset() |
530 { | 530 { |
531 frameDestroyed(); | 531 m_frameObserver->contextDestroyed(); |
532 | 532 |
533 m_screen = nullptr; | 533 m_screen = nullptr; |
534 m_history = nullptr; | 534 m_history = nullptr; |
535 m_locationbar = nullptr; | 535 m_locationbar = nullptr; |
536 m_menubar = nullptr; | 536 m_menubar = nullptr; |
537 m_personalbar = nullptr; | 537 m_personalbar = nullptr; |
538 m_scrollbars = nullptr; | 538 m_scrollbars = nullptr; |
539 m_statusbar = nullptr; | 539 m_statusbar = nullptr; |
540 m_toolbar = nullptr; | 540 m_toolbar = nullptr; |
541 m_console = nullptr; | 541 m_console = nullptr; |
542 m_navigator = nullptr; | 542 m_navigator = nullptr; |
543 m_media = nullptr; | 543 m_media = nullptr; |
544 m_applicationCache = nullptr; | 544 m_applicationCache = nullptr; |
545 #if ENABLE(ASSERT) | 545 #if ENABLE(ASSERT) |
546 m_hasBeenReset = true; | 546 m_hasBeenReset = true; |
547 #endif | 547 #endif |
548 | 548 |
549 resetLocation(); | |
550 | |
551 LocalDOMWindow::notifyContextDestroyed(); | 549 LocalDOMWindow::notifyContextDestroyed(); |
552 } | 550 } |
553 | 551 |
554 void LocalDOMWindow::sendOrientationChangeEvent() | 552 void LocalDOMWindow::sendOrientationChangeEvent() |
555 { | 553 { |
556 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); | 554 ASSERT(RuntimeEnabledFeatures::orientationEventEnabled()); |
557 ASSERT(frame()->isMainFrame()); | 555 ASSERT(frame()->isMainFrame()); |
558 | 556 |
559 // Before dispatching the event, build a list of all frames in the page | 557 // Before dispatching the event, build a list of all frames in the page |
560 // to send the event to, to mitigate side effects from event handlers | 558 // to send the event to, to mitigate side effects from event handlers |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 { | 658 { |
661 if (!isCurrentlyDisplayedInFrame()) | 659 if (!isCurrentlyDisplayedInFrame()) |
662 return nullptr; | 660 return nullptr; |
663 if (!m_applicationCache) | 661 if (!m_applicationCache) |
664 m_applicationCache = ApplicationCache::create(frame()); | 662 m_applicationCache = ApplicationCache::create(frame()); |
665 return m_applicationCache.get(); | 663 return m_applicationCache.get(); |
666 } | 664 } |
667 | 665 |
668 Navigator* LocalDOMWindow::navigator() const | 666 Navigator* LocalDOMWindow::navigator() const |
669 { | 667 { |
670 if (!isCurrentlyDisplayedInFrame() && (!m_navigator || m_navigator->frame()) ) { | |
dcheng
2015/09/28 06:45:09
I tested with the test case in https://code.google
| |
671 // We return a navigator with null frame instead of returning null | |
672 // pointer as other functions do, in order to allow users to access | |
673 // functions such as navigator.product. | |
674 m_navigator = Navigator::create(nullptr); | |
675 } | |
676 if (!m_navigator) | 668 if (!m_navigator) |
677 m_navigator = Navigator::create(frame()); | 669 m_navigator = Navigator::create(frame()); |
678 // As described above, when not dispayed in the frame, the returning | |
679 // navigator should not be associated with the frame. | |
680 ASSERT(isCurrentlyDisplayedInFrame() || !m_navigator->frame()); | |
681 return m_navigator.get(); | 670 return m_navigator.get(); |
682 } | 671 } |
683 | 672 |
684 void LocalDOMWindow::schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent> ev ent, LocalDOMWindow* source, SecurityOrigin* target, PassRefPtrWillBeRawPtr<Scri ptCallStack> stackTrace) | 673 void LocalDOMWindow::schedulePostMessage(PassRefPtrWillBeRawPtr<MessageEvent> ev ent, LocalDOMWindow* source, SecurityOrigin* target, PassRefPtrWillBeRawPtr<Scri ptCallStack> stackTrace) |
685 { | 674 { |
686 // Schedule the message. | 675 // Schedule the message. |
687 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current Token())); | 676 OwnPtrWillBeRawPtr<PostMessageTimer> timer = adoptPtrWillBeNoop(new PostMess ageTimer(*this, event, source, target, stackTrace, UserGestureIndicator::current Token())); |
688 timer->startOneShot(0, FROM_HERE); | 677 timer->startOneShot(0, FROM_HERE); |
689 timer->suspendIfNeeded(); | 678 timer->suspendIfNeeded(); |
690 m_postMessageTimers.add(timer.release()); | 679 m_postMessageTimers.add(timer.release()); |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1368 { | 1357 { |
1369 RefPtrWillBeRawPtr<Event> loadEvent(Event::create(EventTypeNames::load)); | 1358 RefPtrWillBeRawPtr<Event> loadEvent(Event::create(EventTypeNames::load)); |
1370 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) { | 1359 if (frame() && frame()->loader().documentLoader() && !frame()->loader().docu mentLoader()->timing().loadEventStart()) { |
1371 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching | 1360 // The DocumentLoader (and thus its DocumentLoadTiming) might get destro yed while dispatching |
1372 // the event, so protect it to prevent writing the end time into freed m emory. | 1361 // the event, so protect it to prevent writing the end time into freed m emory. |
1373 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = frame()->loader().do cumentLoader(); | 1362 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = frame()->loader().do cumentLoader(); |
1374 DocumentLoadTiming& timing = documentLoader->timing(); | 1363 DocumentLoadTiming& timing = documentLoader->timing(); |
1375 timing.markLoadEventStart(); | 1364 timing.markLoadEventStart(); |
1376 dispatchEvent(loadEvent, document()); | 1365 dispatchEvent(loadEvent, document()); |
1377 timing.markLoadEventEnd(); | 1366 timing.markLoadEventEnd(); |
1378 } else | 1367 } else { |
1379 dispatchEvent(loadEvent, document()); | 1368 dispatchEvent(loadEvent, document()); |
1369 } | |
dcheng
2015/09/28 06:45:09
I'm not sure why, but the presubmit checks are ran
| |
1380 | 1370 |
1381 // For load events, send a separate load event to the enclosing frame only. | 1371 // For load events, send a separate load event to the enclosing frame only. |
1382 // This is a DOM extension and is independent of bubbling/capturing rules of | 1372 // This is a DOM extension and is independent of bubbling/capturing rules of |
1383 // the DOM. | 1373 // the DOM. |
1384 FrameOwner* owner = frame() ? frame()->owner() : nullptr; | 1374 FrameOwner* owner = frame() ? frame()->owner() : nullptr; |
1385 if (owner) | 1375 if (owner) |
1386 owner->dispatchLoad(); | 1376 owner->dispatchLoad(); |
1387 | 1377 |
1388 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkLoad", TRACE_EVENT_SCOPE_THRE AD, "data", InspectorMarkLoadEvent::data(frame())); | 1378 TRACE_EVENT_INSTANT1("devtools.timeline", "MarkLoad", TRACE_EVENT_SCOPE_THRE AD, "data", InspectorMarkLoadEvent::data(frame())); |
1389 InspectorInstrumentation::loadEventFired(frame()); | 1379 InspectorInstrumentation::loadEventFired(frame()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1455 if (!enteredWindow->allowPopUp()) { | 1445 if (!enteredWindow->allowPopUp()) { |
1456 // Because FrameTree::find() returns true for empty strings, we must che ck for empty frame names. | 1446 // Because FrameTree::find() returns true for empty strings, we must che ck for empty frame names. |
1457 // Otherwise, illegitimate window.open() calls with no name will pass ri ght through the popup blocker. | 1447 // Otherwise, illegitimate window.open() calls with no name will pass ri ght through the popup blocker. |
1458 if (frameName.isEmpty() || !frame()->tree().find(frameName)) | 1448 if (frameName.isEmpty() || !frame()->tree().find(frameName)) |
1459 return nullptr; | 1449 return nullptr; |
1460 } | 1450 } |
1461 | 1451 |
1462 // Get the target frame for the special cases of _top and _parent. | 1452 // Get the target frame for the special cases of _top and _parent. |
1463 // In those cases, we schedule a location change right now and return early. | 1453 // In those cases, we schedule a location change right now and return early. |
1464 Frame* targetFrame = nullptr; | 1454 Frame* targetFrame = nullptr; |
1465 if (frameName == "_top") | 1455 if (frameName == "_top") { |
1466 targetFrame = frame()->tree().top(); | 1456 targetFrame = frame()->tree().top(); |
1467 else if (frameName == "_parent") { | 1457 } else if (frameName == "_parent") { |
1468 if (Frame* parent = frame()->tree().parent()) | 1458 if (Frame* parent = frame()->tree().parent()) |
1469 targetFrame = parent; | 1459 targetFrame = parent; |
1470 else | 1460 else |
1471 targetFrame = frame(); | 1461 targetFrame = frame(); |
1472 } | 1462 } |
1473 | 1463 |
1474 if (targetFrame) { | 1464 if (targetFrame) { |
1475 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*t argetFrame)) | 1465 if (!activeDocument->frame() || !activeDocument->frame()->canNavigate(*t argetFrame)) |
1476 return nullptr; | 1466 return nullptr; |
1477 | 1467 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1511 visitor->trace(m_eventQueue); | 1501 visitor->trace(m_eventQueue); |
1512 visitor->trace(m_postMessageTimers); | 1502 visitor->trace(m_postMessageTimers); |
1513 HeapSupplementable<LocalDOMWindow>::trace(visitor); | 1503 HeapSupplementable<LocalDOMWindow>::trace(visitor); |
1514 #endif | 1504 #endif |
1515 DOMWindow::trace(visitor); | 1505 DOMWindow::trace(visitor); |
1516 DOMWindowLifecycleNotifier::trace(visitor); | 1506 DOMWindowLifecycleNotifier::trace(visitor); |
1517 } | 1507 } |
1518 | 1508 |
1519 LocalFrame* LocalDOMWindow::frame() const | 1509 LocalFrame* LocalDOMWindow::frame() const |
1520 { | 1510 { |
1511 // If the LocalDOMWindow still has a frame reference, that frame must point | |
1512 // back to this LocalDOMWindow: otherwise, it's easy to get into a situation | |
1513 // where script execution leaks between different LocalDOMWindows. | |
1514 if (m_frameObserver->frame()) | |
1515 ASSERT_WITH_SECURITY_IMPLICATION(m_frameObserver->frame()->domWindow() = = this); | |
1521 return m_frameObserver->frame(); | 1516 return m_frameObserver->frame(); |
1522 } | 1517 } |
1523 | 1518 |
1524 } // namespace blink | 1519 } // namespace blink |
OLD | NEW |