Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57675

QQuickWebEngineNewViewRequest::requestedUrl is empty when opening window from JavaScript

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.9
    • 5.9
    • WebEngine
    • None
    • Linux Mint 17.3, Qt 5.9 (dev branch), developer build.
    • 93f9eed62db271ae4b8896f48df72a956f3ce7be

      In QQuickWebEngineView, when you open a new window from JavaScript, the newViewRequested signal gives you a QQuickWebEngineNewViewRequest instance with an empty requestedUrl.

      Example:

          QUrl url("data:text/html,<html><body>test</body></html>");
          QQuickWebEngineView *view = new QQuickWebEngineView();
      
          connect(view, &QQuickWebEngineView::newViewRequested, this, [this, url](QQuickWebEngineNewViewRequest *request){
              qDebug() << "Expected " << url;
              qDebug() << "Received " << request->requestedUrl();
          });
      
          view->loadHtml("<html><script>window.open('" + url.toString() + "');</script></html>");
      
          QSignalSpy spy(view, &QQuickWebEngineView::newViewRequested);
          spy.wait();
      
          delete view;
      

      The example prints

      Expected QUrl("data:text/html,%3Chtml%3E%3Cbody%3Etest%3C/body%3E%3C/html%3E")
      Received QUrl("")
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            viengelm Viktor Engelmann
            viengelm Viktor Engelmann
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes