Changeset 247873 in webkit


Ignore:
Timestamp:
Jul 26, 2019 1:34:28 PM (5 years ago)
Author:
youenn@apple.com
Message:

slides.google.com: opening speaker notes while presenting causes a fatal error in the web app on iPad
https://bugs.webkit.org/show_bug.cgi?id=199933
<rdar://problem/53034345>

Reviewed by Darin Adler.

docs.google.com might sometimes try to window.open an about URL that not about:blank or about:srcdoc.
In that case, WebKit is opening a window but is considering that the window is cross origin with its opener.
This breaks docs.google.com as they want to access the website.
Add a site-specific hack so as to treat all about URLs being opened through window.open as about:blank.

Manually tested on docs.google.com website.

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::createWindow):
(WebCore::DOMWindow::open):

  • page/Quirks.cpp:

(WebCore::Quirks::needsYouTubeOverflowScrollQuirk const):
(WebCore::Quirks::shouldOpenAsAboutBlank const):

  • page/Quirks.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247862 r247873  
     12019-07-26  Youenn Fablet  <youenn@apple.com>
     2
     3        slides.google.com: opening speaker notes while presenting causes a fatal error in the web app on iPad
     4        https://bugs.webkit.org/show_bug.cgi?id=199933
     5        <rdar://problem/53034345>
     6
     7        Reviewed by Darin Adler.
     8
     9        docs.google.com might sometimes try to window.open an about URL that not about:blank or about:srcdoc.
     10        In that case, WebKit is opening a window but is considering that the window is cross origin with its opener.
     11        This breaks docs.google.com as they want to access the website.
     12        Add a site-specific hack so as to treat all about URLs being opened through window.open as about:blank.
     13
     14        Manually tested on docs.google.com website.
     15
     16        * page/DOMWindow.cpp:
     17        (WebCore::DOMWindow::createWindow):
     18        (WebCore::DOMWindow::open):
     19        * page/Quirks.cpp:
     20        (WebCore::Quirks::needsYouTubeOverflowScrollQuirk const):
     21        (WebCore::Quirks::shouldOpenAsAboutBlank const):
     22        * page/Quirks.h:
     23
    1242019-07-26  Alexander Mikhaylenko  <exalm7659@gmail.com>
    225
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r247555 r247873  
    23962396}
    23972397
    2398 ExceptionOr<RefPtr<WindowProxy>> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlString, const AtomString& frameName, const String& windowFeaturesString)
     2398ExceptionOr<RefPtr<WindowProxy>> DOMWindow::open(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& urlStringToOpen, const AtomString& frameName, const String& windowFeaturesString)
    23992399{
    24002400    if (!isCurrentlyDisplayedInFrame())
     
    24082408    if (!firstFrame)
    24092409        return RefPtr<WindowProxy> { nullptr };
     2410
     2411    auto urlString = urlStringToOpen;
     2412    if (activeDocument->quirks().shouldOpenAsAboutBlank(urlStringToOpen))
     2413        urlString = "about:blank"_s;
    24102414
    24112415#if ENABLE(CONTENT_EXTENSIONS)
  • trunk/Source/WebCore/page/Quirks.cpp

    r247840 r247873  
    3131#include "Document.h"
    3232#include "DocumentLoader.h"
     33#include "FrameLoader.h"
    3334#include "HTMLMetaElement.h"
    3435#include "HTMLObjectElement.h"
     
    456457}
    457458
    458 }
     459bool Quirks::shouldOpenAsAboutBlank(const String& stringToOpen) const
     460{
     461#if PLATFORM(IOS_FAMILY)
     462    if (!needsQuirks())
     463        return false;
     464
     465    auto openerURL = m_document->url();
     466    if (!equalLettersIgnoringASCIICase(openerURL.host(), "docs.google.com"))
     467        return false;
     468
     469    if (!m_document->frame() || !m_document->frame()->loader().userAgentForJavaScript(openerURL).contains("Macintosh"))
     470        return false;
     471
     472    URL urlToOpen { URL { }, stringToOpen };
     473    if (!urlToOpen.protocolIsAbout())
     474        return false;
     475
     476    return !equalLettersIgnoringASCIICase(urlToOpen.host(), "blank") && !equalLettersIgnoringASCIICase(urlToOpen.host(), "srcdoc");
     477#else
     478    UNUSED_PARAM(stringToOpen);
     479    return false;
     480#endif
     481}
     482
     483}
  • trunk/Source/WebCore/page/Quirks.h

    r247840 r247873  
    7171    bool needsYouTubeOverflowScrollQuirk() const;
    7272
     73    bool shouldOpenAsAboutBlank(const String&) const;
     74
    7375private:
    7476    bool needsQuirks() const;
Note: See TracChangeset for help on using the changeset viewer.