4

I'm trying to use SpeedOf.Me API in a Qt application with QtWebKit. Unfortunately, the speed test doesn't seem to work correctly. Precisely, when I open http://speedof.me/api/doc/sample_advanced.html in WebView and click Start Test, then:

  1. download test runs well (SomApi.onProgress with progress.type="download")
  2. then "Test result" shows up with a reasonable download speed but with a very strange upload speed (SomApi.onTestCompleted)
  3. eventually upload test starts (SomApi.onProgress with progress.type="upload")

Test result is not updated after the upload test. In the normal scenario, the order should be, of course: download test, upload test, and then, display results. Am I doing something wrong or is it just the way the Qt WebKit is thought to work? Can you suggest any workaround?

Because the URL is fundamental in the code attached below and I can't post the link more then twice, I've replaced all occurrences of http://speedof.me/api/doc/sample_advanced.html with __URL__.

How to reproduce this bug?

I was getting this behaviour in all variants of Qt binding of WebKit, including Qt Quick code below (Arch Linux, qml binary version 1.0, built with Qt version 5.2.1), a similar code in Qt Widgets (run both on Arch Linux with Qt5 and on Ubuntu 12.04 with Qt4) and the same happens on a Qt-based web browser Arora (from Arch repo).

import QtQuick 2.0
import QtQuick.Controls 1.0
import QtWebKit 3.0

ScrollView {
    width: 1280
    height: 720
    WebView {
        id: webview
        url: "__URL__"
        anchors.fill: parent
        onNavigationRequested: {
            // detect URL scheme prefix, most likely an external link
            var schemaRE = /^\w+:/;
            if (schemaRE.test(request.url)) {
                request.action = WebView.AcceptRequest;
            } else {
                request.action = WebView.IgnoreRequest;
                // delegate request.url here
            }
        }
   }
}

How to reproduce correct behaviour?

The script runs correctly on most of standard web browsers (I was testing Chromium, Firefox, Safari), but it also runs well on GTK WebKit.

from gi.repository import Gtk, WebKit
win = Gtk.Window()
view = WebKit.WebView()
view.load_uri("__URL__")
win.add(view)
win.show_all()
Gtk.main()

(Python 3.4.0, WebKit 2.4.1, module gi 3.12.1)

What doesn't seem to be the answer?

I've been struggling for a long time to address this bug and have even contacted support of SpeedOf.Me. I'd like to post here some of my observations.

Disabled or unimplemented XHR2

What is interesting, the upload test itself seems to work well. It's just the order which is wrong and, in the end, the test result. However, SpeedOf.Me support suggested that my browser may lack of "full support for AJAX level 2". So I put here a few lines from WebKit Developer console (the same version, on which the speedtest failed). According to some posts here (How can I check if the browser support HTML5 file upload (FormData object)?) they prove that XHR2 and AJAX level 2 is on, don't they?

> Date: Thu May 15 2014 core.js:8
> Ver: 2.7 core.js:8
> URL: __URL__ core.js:8
> User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) view Safari/538.1 core.js:8
window.FormData
FormDataConstructor {prototype: FormDataPrototype}
var xhr = new XMLHttpRequest()
undefined
xhr
XMLHttpRequest {readyState: 0, timeout: 0, onloadend: null, withCredentials: false, onloadstart: null…}
('upload' in xhr) && ('onprogress' in xhr)
true
new XMLHttpRequest().upload
XMLHttpRequestUpload {onabort: null, onload: null, onprogress: null, onerror: null, onloadstart: null…}

UserAgent string

Modifying UserAgent doesn't influence the behaviour.

Community
  • 1
  • 1
mlu
  • 137
  • 2
  • 8
  • Have you been able to find a solution? Any updates? – advncd Sep 23 '16 at 17:51
  • 1
    I don't know if this issue still occurs with fresh versions of QtWebKit and that speed test library. However, one workaround I found at that time was to use API handler `onProgress` rather than `onTestCompleted` and check for `percentDone` and `type` properties. The full example can be found here: https://github.com/Linoxide/linspeed/blob/master/speedtest.html#L38. – mlu Sep 27 '16 at 11:36

0 Answers0