From 568d69eb5c1799dd8706df1ed3a1c85a778c6799 Mon Sep 17 00:00:00 2001
From: Michal Klocek <michal.klocek@qt.io>
Date: Fri, 26 Apr 2019 17:54:17 +0200
Subject: [PATCH] Do not blacklist webChannelWithBadString
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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: Jüri Valdmann <juri.valdmann@qt.io>
---
 tests/auto/widgets/qwebenginescript/BLACKLIST                | 3 ---
 tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp | 4 +++-
 tests/auto/widgets/widgets.pro                               | 3 +--
 3 files changed, 4 insertions(+), 6 deletions(-)
 delete mode 100644 tests/auto/widgets/qwebenginescript/BLACKLIST

diff --git a/tests/auto/widgets/qwebenginescript/BLACKLIST b/tests/auto/widgets/qwebenginescript/BLACKLIST
deleted file mode 100644
index b641aaf04..000000000
--- a/tests/auto/widgets/qwebenginescript/BLACKLIST
+++ /dev/null
@@ -1,3 +0,0 @@
-# FIXME post 72-merge
-[webChannelWithBadString]
-*
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
index be9e59b8c..9a2ee9311 100644
--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
@@ -546,7 +546,9 @@ void tst_QWebEngineScript::webChannelWithBadString()
     page.setWebChannel(&channel);
     page.setUrl(QStringLiteral("qrc:/resources/webChannelWithBadString.html"));
     QVERIFY(hostSpy.wait(20000));
-    QCOMPARE(host.text(), QString(QChar(QChar::ReplacementCharacter)));
+    // expect 0xD800 see https://chromium-review.googlesource.com/c/1282993
+    QChar data(0xd800);
+    QCOMPARE(host.text(), data);
 }
 #endif
 QTEST_MAIN(tst_QWebEngineScript)
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 104c85895..92159bf83 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -42,7 +42,6 @@ qtConfig(webengine-spellchecker):!cross_compile {
 boot2qt: SUBDIRS -= accessibility defaultsurfaceformat devtools \
                     qwebenginepage \
                     qwebengineprofile  \
-                    qwebengineview  \
-                    qwebenginescript
+                    qwebengineview
 
 win32: SUBDIRS -= offscreen
-- 
GitLab