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

QWebEngineScripts with DocumentCreation don't run on view-source page

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.12.0
    • 5.10.0
    • WebEngine
    • None

    Description

      With this code, the script is never run:

      #include <QApplication>
      #include <QWebEngineView>
      #include <QWebEngineScript>
      #include <QWebEngineScriptCollection>
      #include <QUrl>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QWebEngineView view;
      
          QWebEngineScript script;
          script.setInjectionPoint(QWebEngineScript::DocumentCreation);
          // script.setInjectionPoint(QWebEngineScript::DocumentReady);
          script.setSourceCode("console.log('Hello World!');");
          view.page()->scripts().insert(script);
      
          view.load(QUrl("view-source:https://qutebrowser.org"));
          view.show();
          return app.exec();
      }
      

      When using DocumentReady instead of DocumentCreation, it runs fine though.

      Attachments

        Activity

          People

            juri.valdmann Jüri Valdmann (Inactive)
            the compiler Florian Bruhin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: