1. May 03, 2019
    • Michal Klocek's avatar
      Do not blacklist webChannelWithBadString · 568d69eb
      Michal Klocek authored
      This commit is about documenting some weird new behavior.
      
      Since Chormium 72 our webChannelWithBadString fails. This is
      fascinating issue and can be tracked down to commit in Chromium
      https://chromium-review.googlesource.com/c/1282993
      
      
      which "fixes" well-forming of JSON.strigify. This function
      is used by webchannel.js to send data through webchannel
      transport. In c++ land we get now for invalid utf16 replacement
      in form of '\\u' + i.toString(16).padStart(4, '0').
      This sadly does not trigger any longer REPLACE_INVALID_UTF8 in
      WebChannelTransport::NativeQtSendMessage. Moreover
      this goes even "worse" since QMetaObjectPublisher
      will create invalid utf16 form raw "\ud800" string -> '\ud800'.
      
      This is not an error per se, since test creates invalid utf16
      character in javascript  and it ends as invalid utf8 character in c++.
      
      Btw enable test on qemu.
      
      Change-Id: I36f2df417d7b9f3f2113792f08025821737d8d01
      Reviewed-by: default avatarJüri Valdmann <juri.valdmann@qt.io>
      568d69eb
  2. Apr 08, 2019
    • Jüri Valdmann's avatar
      Run non-MainWorld DocumentCreation scripts even if JS disabled · 44303861
      Jüri Valdmann authored
      
      Fixes regression, introduced by the fix for QTBUG-66011, where setting
      JavascriptEnabled to false stops all scripts from running instead of only
      MainWorld scripts (as documented). Only the DocumentCreation injection point is
      affected.
      
      The original change which introduced the regression consisted of moving the
      DocumentCreation injection point from
      
          ContentRendererClient::RunScriptsAtDocumentStart
      
      to
      
          RenderFrameObserver::DidClearWindowObject.
      
      The problem of scripts not working on view-source URLs was fixed by this move,
      but it turns out that the call to DidClearWindowObject happens to be conditional
      on Document::CanExecuteScripts and this is, of course, false if JS is disabled.
      Hence the regression.
      
      This new patch moves the injection point again to a task launched from
      
          RenderFrameObserver::DidCommitProvisionalLoad.
      
      DidCommitProvisionalLoad and DidClearWindowObject are both indirectly called
      from DocumentLoader::InstallNewDocument, however the former is called before the
      Document is opened and is therefore too early for script execution. As such, the
      execution is delayed by posting a task which, in theory, should be scheduled
      very soon after the normal call to DidClearWindowObject.
      
      Fixes: QTBUG-74304
      Change-Id: Iac8714bcc5651c287b73181811af26996d955af5
      Reviewed-by: default avatarAllan Sandfeld Jensen <allan.jensen@qt.io>
      44303861
  3. Mar 23, 2019
  4. Oct 23, 2018
  5. Oct 08, 2018
  6. Aug 09, 2018
  7. May 17, 2018
  8. May 16, 2018
    • Jüri Valdmann's avatar
      Replace invalid characters in WebChannel messages · 8476245d
      Jüri Valdmann authored
      
      Turns out JavaScript's JSON.stringify is not guaranteed to produce valid UTF-16
      strings. It is possible in JavaScript to produce string objects which contain
      invalid code units (unmatched surrogate pairs) and JSON.stringify will simply
      copy this data to it's output. However, such a string cannot be losslessly
      converted to UTF-8 and this leads to fun errors in WebChannelIPCTransport.
      
      This patch
      
        - Adds a test for the scenario above.
      
        - Changes WebChannelIPCTransport to replace these invalid code units with the
          Unicode replacement character U+FFFD.
      
        - Changes WebChannelIPCTransportHost to validate the data it gets from the
          renderer. Not validating the data defeats the whole point of Chromium's
          fancy multi-process architecture: the renderer is not to be trusted.
      
        - Changes WebChannelIPCTransport to throw JavaScript exceptions for various
          errors (missing argument, wrong type, invalid JSON). Seems like the polite
          thing to do.
      
      Task-number: QTBUG-61969
      Change-Id: I83275a0eaed77109dc458b80e27217108dde9f7b
      Reviewed-by: default avatarMichal Klocek <michal.klocek@qt.io>
      8476245d
  9. Apr 07, 2018
  10. Apr 03, 2018
    • Jüri Valdmann's avatar
      Add tst_qwebenginescript loadEvents · ef0bebc8
      Jüri Valdmann authored
      
      Replace injectionPoint test with a timeout-less version that uses
      
      - both a single-frame and a multi-frame page
      - both main and isolated worlds
      - cross-process navigation
      - window.open
      - profile-wide scripts
      
      Task-number: QTBUG-66338
      Change-Id: Ica4acb8ada4acc38aa5e1ca00e7512a2e69b785f
      Reviewed-by: default avatarMichael Brüning <michael.bruning@qt.io>
      ef0bebc8
  11. Mar 22, 2018
    • Jüri Valdmann's avatar
      Make WebChannelIPCTransport into a RenderFrameObserver · 58658bc5
      Jüri Valdmann authored
      As of version 63, Chromium creates proxy frames also for the main frame in the
      frame tree during cross-process navigations. This leads to a segmentation fault
      in WebChannelIPCTransport because we assume that all main frames are local.
      
      See https://crrev.com/27caae83cb530daaf49f9a38793e427cdf493a65
      
       for details.
      
      This patch refactors the renderer-side WebChannelIPCTransport from a
      RenderViewObserver into a RenderFrameObserver, which prevents the segmentation
      fault since the RenderFrameObserver is not created for proxy frames. Most likely
      this would have to be done eventually anyway since the RenderView and
      RenderViewObserver classes are deprecated and will likely be removed as part of
      the Site Isolation project.
      
      Installation is changed to follow Chromium's RenderFrameImpl in the sense of
      performing the installation from RenderFrameObserver::DidClearWindowObject
      instead of ContentRendererClient::RunScriptsAtDocumentStart. This has the
      benefit of avoiding the ScriptForbiddenScope DCHECK.
      
      Additionally there are the following minor changes:
      
        - The deprecated parameterless version of v8::Value::ToObject() method is
          replaced with v8::Value::IsObject() check and v8::Local::Cast.
      
        - The deprecated v8::Handle typedef is replaced with v8::Local.
      
        - The deprecated single-parameter WebContentsObserver::OnMessageReceived is
          replaced with the new two-parameter version.
      
        - blink::MainThreadIsolate() is used instead of v8::Isolate::GetCurrent() for
          Install/Uninstall since we know we are executing on the main thread.
      
        - WebChannelIPCTransportHost is changed to ignore messages from unexpected
          renderers in case something goes wrong with the renderers.
      
        - Logging is added to WebChannelIPCTransportHost for debugging purposes.
      
      Some new unit tests are added, all of which fail with the old version.
      
      Task-number: QTBUG-66333
      Change-Id: I936d142fb042d9f936a3f9d08d4328ecba595f1f
      Reviewed-by: default avatarMichal Klocek <michal.klocek@qt.io>
      58658bc5
  12. Dec 30, 2017
  13. Oct 18, 2017
  14. Sep 11, 2017
  15. Nov 29, 2016
  16. Jun 13, 2016
  17. Jan 15, 2016
  18. Jan 08, 2016
  19. Nov 12, 2015
  20. Nov 06, 2015
    • Kai Koehne's avatar
      Print JS console messages by default · be8c12a8
      Kai Koehne authored
      
      Change the behavior of QWebEnginePage/WebEngineView
      to print JavaScript console.warn and console.error messages
      by default in a 'js' logging category. This matches also
      the behavior for QtQml, where console messages end up in
      a 'qml' logging category by default.
      
      So far access to the JavaScript console required either use
      of the remote debugging functionality, subclassing of
      QWebEnginePage, or implementing a custom handler.
      Anyhow, even then writing a seamless forwarding of
      the data and metadata to the Qt message handler is
      difficult. This patches implements this forwarding by
      default.
      
      The behavior can be changed by either setting up rules
      for the 'js' category, e.g.
      
        setFilterRules("js.*=false");
      
      or by implementing onJavaScriptConsoleMessage(),
      or overriding QWebEnginePage::javaScriptConsoleMessage.
      
      [ChangeLog] Unhandled JS console messages are now
      forwarded to to the Qt message handler inside a 'js'
      category.
      
      Change-Id: I5480383a80dcf7a122496f9b7915264ef9036db3
      Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
      be8c12a8
  21. Aug 25, 2015
  22. Apr 07, 2015
  23. Mar 18, 2015