Skip to content

Truly independent web browser

LibWeb: Load URL font faces in workers

Tim Ledbetter16f8a4e9aeb4
diff --git a/Libraries/LibWeb/CSS/FontComputer.cpp b/Libraries/LibWeb/CSS/FontComputer.cpp
index 614f5f2c5b3..2d9e88cadfe 100644
--- a/Libraries/LibWeb/CSS/FontComputer.cpp
+++ b/Libraries/LibWeb/CSS/FontComputer.cpp
@@ -27,6 +27,8 @@
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/Fetch/Infrastructure/HTTP/MIME.h>
#include <LibWeb/Fetch/Response.h>
+#include <LibWeb/HTML/Window.h>
+#include <LibWeb/HTML/WorkerGlobalScope.h>
#include <LibWeb/Layout/RenderDocument.h>
#include <LibWeb/MimeSniff/Resource.h>
#include <LibWeb/Page/Page.h>
@@ -51,8 +53,9 @@ struct Traits<Web::CSS::FontFeatureValuesCacheKey> : public DefaultTraits<Web::C
namespace Web::CSS {
-FontComputer::FontComputer()
- : m_font_cascade_memo(FontCascadeMemo::create())
+FontComputer::FontComputer(HTML::EnvironmentSettingsObject& environment_settings_object)
+ : m_environment_settings_object(environment_settings_object)
+ , m_font_cascade_memo(FontCascadeMemo::create())
{
}
@@ -116,7 +119,7 @@ void FontLoader::did_request_for_rendering()
// INTEROP: Delay the document load event til the fetch for this font has settled. Blink, Gecko, and WebKit all
// keep the document from completing while a font load requested for rendering is pending — so pages
// that measure font-dependent geometry in a load-event handler see the loaded font, not a fallback.
- if (is_loading() && !m_document_load_event_delayer.has_value())
+ if (is_loading() && !m_document_load_event_delayer.has_value() && m_font_computer->has_document())
m_document_load_event_delayer.emplace(m_font_computer->document());
}
@@ -250,6 +253,7 @@ void FontComputer::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_document);
+ visitor.visit(m_environment_settings_object);
for (auto& [_, faces] : m_font_faces)
visitor.visit(faces);
for (auto& [_, loader] : m_loaders_by_source)
@@ -428,7 +432,7 @@ void FontComputer::invalidate_changed_font_cascades(Vector<Utf16FlyString> const
invalidated_font_lists.append(font_list.ptr());
return true;
});
- if (!invalidated_font_lists.is_empty())
+ if (!invalidated_font_lists.is_empty() && m_document)
record_font_input_changes({}, invalidated_font_lists);
request_wanted_web_faces();
}
@@ -652,7 +656,7 @@ GC::Ptr<FontLoader> FontComputer::load_font_face(ReadonlySpan<FontLoader::Source
}
RuleOrDeclaration rule_or_declaration {
- .environment_settings_object = document().relevant_settings_object(),
+ .environment_settings_object = m_document ? m_document->relevant_settings_object() : *m_environment_settings_object,
.value = RuleOrDeclaration::Rule {
.parent_style_sheet = parent_style_sheet,
},
@@ -757,4 +761,13 @@ void FontComputer::unload_fonts_from_sheet(StyleSheetState& sheet)
});
}
+Optional<FontComputer&> font_computer_for_font_source(JS::Object& global)
+{
+ if (auto* window = HTML::window_from_global_object(global))
+ return window->associated_document().font_computer();
+ if (auto* worker_global_scope = Bindings::worker_global_scope_from_global_object(global))
+ return worker_global_scope->font_computer();
+ return {};
+}
+
}
diff --git a/Libraries/LibWeb/CSS/FontComputer.h b/Libraries/LibWeb/CSS/FontComputer.h
index 371d451c434..2640d7d0173 100644
--- a/Libraries/LibWeb/CSS/FontComputer.h
+++ b/Libraries/LibWeb/CSS/FontComputer.h
@@ -180,10 +180,11 @@ class WEB_API FontComputer final : public GC::Cell {
GC_DECLARE_ALLOCATOR(FontComputer);
public:
- FontComputer();
+ explicit FontComputer(HTML::EnvironmentSettingsObject&);
explicit FontComputer(DOM::Document&);
virtual ~FontComputer() override;
+ bool has_document() const { return m_document != nullptr; }
DOM::Document& document() { return *m_document; }
DOM::Document const& document() const { return *m_document; }
@@ -238,6 +239,7 @@ private:
NonnullRefPtr<FontFeatureValuesByScope const> font_feature_values_by_scope() const;
GC::Ptr<DOM::Document> m_document;
+ GC::Ptr<HTML::EnvironmentSettingsObject> m_environment_settings_object;
HashMap<FontFaceKey, Vector<NonnullRefPtr<FontFaceState>>> m_font_faces;
HashMap<String, GC::Ref<FontLoader>> m_loaders_by_source;
@@ -260,4 +262,6 @@ private:
Vector<Gfx::FontCascadeList const*> m_font_lists_changed_beside_flown_transaction;
};
+WEB_API Optional<FontComputer&> font_computer_for_font_source(JS::Object& global);
+
}
diff --git a/Libraries/LibWeb/CSS/FontFace.cpp b/Libraries/LibWeb/CSS/FontFace.cpp
index 3184a3a4965..c3f28b8fd20 100644
--- a/Libraries/LibWeb/CSS/FontFace.cpp
+++ b/Libraries/LibWeb/CSS/FontFace.cpp
@@ -42,7 +42,6 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
-#include <LibWeb/HTML/Window.h>
#include <LibWeb/Platform/Timer.h>
#include <LibWeb/WebIDL/AbstractOperations.h>
#include <LibWeb/WebIDL/Buffers.h>
@@ -576,9 +575,8 @@ void FontFaceState::reject_status_promise(WebIDL::Exception reason)
Optional<FontComputer&> FontFaceState::font_computer() const
{
for (auto& font_face_set : m_containing_sets) {
- auto& global = font_face_set->relevant_settings_object().global_object();
- if (auto* window = HTML::window_from_global_object(global))
- return window->associated_document().font_computer();
+ if (auto font_computer = font_computer_for_font_source(font_face_set->relevant_settings_object().global_object()); font_computer.has_value())
+ return font_computer;
}
return {};
}
@@ -950,17 +948,11 @@ void FontFaceState::load_for_style()
}));
});
- // FIXME: We should probably put the 'font cache' on the WindowOrWorkerGlobalScope instead of tying it to the document's style computer
- if (auto document = m_environment->responsible_document()) {
- auto& font_computer = document->font_computer();
-
- if (auto loader = font_computer.load_font_face(m_urls, m_source_style_sheet, move(on_load))) {
+ if (auto font_computer = font_computer_for_font_source(m_environment->global_object()); font_computer.has_value()) {
+ if (auto loader = font_computer->load_font_face(m_urls, m_source_style_sheet, move(on_load))) {
m_font_loader = loader;
loader->start_loading_next_source();
}
- } else {
- // FIXME: Don't know how to load fonts in workers! They don't have a StyleComputer
- dbgln("FIXME: Worker font loading not implemented");
}
}
diff --git a/Libraries/LibWeb/CSS/FontFaceSet.cpp b/Libraries/LibWeb/CSS/FontFaceSet.cpp
index 79b5bf171ef..ec6cf32acb0 100644
--- a/Libraries/LibWeb/CSS/FontFaceSet.cpp
+++ b/Libraries/LibWeb/CSS/FontFaceSet.cpp
@@ -110,9 +110,8 @@ void FontFaceSet::add_css_connected_font(NonnullRefPtr<FontFaceState> face)
face->add_to_set(*this);
if (face->should_be_registered_with_font_computer()) {
- auto& global = relevant_settings_object().global_object();
- if (auto* window = HTML::window_from_global_object(global))
- window->associated_document().font_computer().register_font_face(face);
+ if (auto font_computer = font_computer_for_font_source(relevant_settings_object().global_object()); font_computer.has_value())
+ font_computer->register_font_face(face);
}
// 4. If font’s status attribute is "loading"
@@ -211,9 +210,8 @@ bool FontFaceSet::remove_font_face(NonnullRefPtr<FontFaceState> face, AllowCSSCo
return false;
if (face->should_be_registered_with_font_computer()) {
- auto& global = relevant_settings_object().global_object();
- if (auto* window = HTML::window_from_global_object(global))
- window->associated_document().font_computer().unregister_font_face(*face);
+ if (auto font_computer = font_computer_for_font_source(relevant_settings_object().global_object()); font_computer.has_value())
+ font_computer->unregister_font_face(*face);
}
// 2. Let deleted be the result of removing font from the FontFaceSet’s set entries.
@@ -241,12 +239,12 @@ void FontFaceSet::clear()
{
// 1. Remove all non-CSS-connected items from the FontFaceSet's set entries,
// its [[LoadedFonts]] list, and its [[FailedFonts]] list.
- auto* window = HTML::window_from_global_object(relevant_settings_object().global_object());
+ auto font_computer = font_computer_for_font_source(relevant_settings_object().global_object());
for (auto& font_face : m_font_faces) {
if (font_face->is_css_connected())
continue;
- if (window && font_face->should_be_registered_with_font_computer())
- window->associated_document().font_computer().unregister_font_face(font_face);
+ if (font_computer.has_value() && font_face->should_be_registered_with_font_computer())
+ font_computer->unregister_font_face(font_face);
Bindings::did_remove_font_face(*this, font_face);
font_face->remove_from_set(*this);
}
diff --git a/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp
index 28dc388bbae..e89f1e8828c 100644
--- a/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp
+++ b/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp
@@ -170,15 +170,18 @@ ENUMERATE_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(__ENUMERATE)
GC::Ref<CSS::FontFaceSet> WorkerGlobalScope::fonts()
{
- if (!m_fonts)
+ if (!m_fonts) {
m_fonts = CSS::FontFaceSet::create(relevant_settings_object(*this));
+ // A worker has no document to wait for, so its font source is never pending on the environment.
+ m_fonts->set_is_pending_on_the_environment(false);
+ }
return *m_fonts;
}
CSS::FontComputer& WorkerGlobalScope::font_computer()
{
if (!m_font_computer)
- m_font_computer = heap().allocate<CSS::FontComputer>();
+ m_font_computer = heap().allocate<CSS::FontComputer>(relevant_settings_object(*this));
return *m_font_computer;
}
diff --git a/Tests/LibWeb/Crash/CSS/offscreen-canvas-text-in-worker-while-font-face-loads.html b/Tests/LibWeb/Crash/CSS/offscreen-canvas-text-in-worker-while-font-face-loads.html
new file mode 100644
index 00000000000..d54b980fa13
--- /dev/null
+++ b/Tests/LibWeb/Crash/CSS/offscreen-canvas-text-in-worker-while-font-face-loads.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html class="test-wait">
+<script>
+ const source = `
+ self.fonts.add(new FontFace("Loading", "url(data:,)"));
+ const context = new OffscreenCanvas(100, 100).getContext("2d");
+ context.font = "20px Loading";
+ context.fillText("A", 0, 50);
+ postMessage(null);
+ `;
+ const worker = new Worker(URL.createObjectURL(new Blob([source])));
+ worker.onmessage = () => document.documentElement.classList.remove("test-wait");
+</script>
+</html>
diff --git a/Tests/LibWeb/Crash/wpt-import/css/css-font-loading/fontfaceset-loading-worker-crash.html b/Tests/LibWeb/Crash/wpt-import/css/css-font-loading/fontfaceset-loading-worker-crash.html
new file mode 100644
index 00000000000..552722b6edd
--- /dev/null
+++ b/Tests/LibWeb/Crash/wpt-import/css/css-font-loading/fontfaceset-loading-worker-crash.html
@@ -0,0 +1,7 @@
+<!doctype html>
+<script>
+document.addEventListener("DOMContentLoaded", function() {
+ let a = new SharedWorker("support/fontfaceset-loading-worker.js")
+ a.port.postMessage([], [])
+})
+</script>
diff --git a/Tests/LibWeb/Crash/wpt-import/css/css-font-loading/support/fontfaceset-loading-worker.js b/Tests/LibWeb/Crash/wpt-import/css/css-font-loading/support/fontfaceset-loading-worker.js
new file mode 100644
index 00000000000..73579756614
--- /dev/null
+++ b/Tests/LibWeb/Crash/wpt-import/css/css-font-loading/support/fontfaceset-loading-worker.js
@@ -0,0 +1,8 @@
+onconnect = async function(e) {
+ e.ports[0].onmessage = async () => {
+ let a = new FontFace("family_name_0", "url(/fonts/Ahem.ttf?fontfaceset-loading-worker)")
+ self.close()
+ await a.load()
+ let _ = new File([a])
+ }
+}
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 42fdf0eb104..c3ad3911a8c 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -367,6 +367,7 @@ Text/input/wpt-import/trusted-types/DedicatedWorker-setTimeout-setInterval.html
Text/input/wpt-import/trusted-types/SharedWorker-setTimeout-setInterval.html
Text/input/wpt-import/trusted-types/block-string-assignment-to-DedicatedWorker-setTimeout-setInterval.html
Text/input/wpt-import/trusted-types/block-string-assignment-to-SharedWorker-setTimeout-setInterval.html
+Crash/wpt-import/css/css-font-loading/fontfaceset-loading-worker-crash.html
; CORS fetch failures.
; Fails in other browsers too when loaded from file://.
@@ -466,6 +467,36 @@ Text/input/wpt-import/html/canvas/offscreen/text/2d.text.font.parse.system.worke
Text/input/wpt-import/html/canvas/offscreen/text/2d.text.font.parse.tiny.worker.html
Text/input/wpt-import/html/canvas/offscreen/text/2d.text.font.relative_size.worker.html
Text/input/wpt-import/html/canvas/offscreen/text/2d.text.font.weight.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.html
+Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.html
Text/input/wpt-import/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.canvas.worker.html
Text/input/wpt-import/html/canvas/offscreen/drawing-rectangles-to-the-canvas/2d.fillRect.basic.worker.html
Text/input/wpt-import/html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.getcontext.worker.html
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.txt
new file mode 100644
index 00000000000..71a7f198fef
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textAlign center is the center of the em squares (not the bounding box)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.txt
new file mode 100644
index 00000000000..f6a962bb6ec
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textAlign end with ltr is the right edge
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.txt
new file mode 100644
index 00000000000..49da037a7b7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textAlign end with rtl is the left edge
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.txt
new file mode 100644
index 00000000000..457f7e223c5
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textAlign left is the left of the first em square (not the bounding box)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.txt
new file mode 100644
index 00000000000..da38024c628
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textAlign right is the right of the last em square (not the bounding box)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.txt
new file mode 100644
index 00000000000..154bbba133e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textAlign start with ltr is the left edge
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.txt
new file mode 100644
index 00000000000..490a6734f79
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textAlign start with rtl is the right edge
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.txt
new file mode 100644
index 00000000000..cf5877d439e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass 2d
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.txt
new file mode 100644
index 00000000000..d7807b75505
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textBaseline bottom is the bottom of the em square (not the bounding box)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.txt
new file mode 100644
index 00000000000..4ba173480dd
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textBaseline middle is the middle of the em square (not the bounding box)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.txt
new file mode 100644
index 00000000000..f1ee74ca862
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass textBaseline top is the top of the em square (not the bounding box)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.txt
new file mode 100644
index 00000000000..a97ed69a8ce
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass fillText handles maxWidth based on line size, not bounding box size
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.txt
new file mode 100644
index 00000000000..97ffc018b61
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass fillText works on @font-face fonts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.txt
new file mode 100644
index 00000000000..b0386e8ae61
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass @font-face fonts should work even if they are not used in the page
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.txt
new file mode 100644
index 00000000000..c91912b2bc9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Draw with the font immediately, then wait a bit until and draw again. (This crashes some version of WebKit.)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.txt
new file mode 100644
index 00000000000..cf5877d439e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass 2d
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.txt
new file mode 100644
index 00000000000..c223572f7bc
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass U+0020 is rendered the correct size (1em wide)
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.txt
new file mode 100644
index 00000000000..e0d65f53912
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Space characters at the end of a line are NOT collapsed
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.txt
new file mode 100644
index 00000000000..6acbd662810
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Non-space characters are not converted to U+0020 and collapsed
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.txt
new file mode 100644
index 00000000000..a937cdcdef6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Space characters are converted to U+0020, and are NOT collapsed
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.txt
new file mode 100644
index 00000000000..a937cdcdef6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Space characters are converted to U+0020, and are NOT collapsed
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.txt
new file mode 100644
index 00000000000..d9a20e156d4
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Space characters at the start of a line are NOT collapsed
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.txt
new file mode 100644
index 00000000000..7ccce4c1182
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Testing emHeights
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.txt
new file mode 100644
index 00000000000..405300fee14
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.txt
new file mode 100644
index 00000000000..6374944a270
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Testing fontBoundingBox for OffscreenCanvas with zero descent metric
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.txt
new file mode 100644
index 00000000000..cc0c0ac2f39
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Testing fontBoundingBox for font ahem
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.txt
new file mode 100644
index 00000000000..dd467a99194
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Testing fontBoundingBox measurements
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.txt
new file mode 100644
index 00000000000..a6141209de4
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass The width of character is same as font used
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.txt
new file mode 100644
index 00000000000..8c0418262e1
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass The empty string has zero width
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.txt
new file mode 100644
index 00000000000..d03186cf217
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Pass
+Pass Space characters are converted to U+0020 and NOT collapsed
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.html
new file mode 100644
index 00000000000..511b879ea7a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.align.center.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.js
new file mode 100644
index 00000000000..c11c8437e24
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.center.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.align.center
+// Description:textAlign center is the center of the em squares (not the bounding box)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'center';
+ ctx.fillText('DD', 50, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textAlign center is the center of the em squares (not the bounding box)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.html
new file mode 100644
index 00000000000..8521a26eed8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.js
new file mode 100644
index 00000000000..f5c57694700
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.ltr.worker.js
@@ -0,0 +1,31 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.align.end.ltr
+// Description:textAlign end with ltr is the right edge
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.direction = 'ltr';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'end';
+ ctx.fillText('DD', 100, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textAlign end with ltr is the right edge");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.html
new file mode 100644
index 00000000000..8c4754c9e84
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.js
new file mode 100644
index 00000000000..90e21f41dc2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.end.rtl.worker.js
@@ -0,0 +1,31 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.align.end.rtl
+// Description:textAlign end with rtl is the left edge
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.direction = 'rtl';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'end';
+ ctx.fillText('DD', 0, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textAlign end with rtl is the left edge");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.html
new file mode 100644
index 00000000000..fdf362514c7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.align.left.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.js
new file mode 100644
index 00000000000..0f929696322
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.left.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.align.left
+// Description:textAlign left is the left of the first em square (not the bounding box)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'left';
+ ctx.fillText('DD', 0, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textAlign left is the left of the first em square (not the bounding box)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.html
new file mode 100644
index 00000000000..eb548217cfa
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.align.right.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.js
new file mode 100644
index 00000000000..594192812a0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.right.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.align.right
+// Description:textAlign right is the right of the last em square (not the bounding box)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'right';
+ ctx.fillText('DD', 100, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textAlign right is the right of the last em square (not the bounding box)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.html
new file mode 100644
index 00000000000..7874635ab80
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.js
new file mode 100644
index 00000000000..32e6fc0f20f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.ltr.worker.js
@@ -0,0 +1,31 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.align.start.ltr
+// Description:textAlign start with ltr is the left edge
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.direction = 'ltr';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'start';
+ ctx.fillText('DD', 0, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textAlign start with ltr is the left edge");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.html
new file mode 100644
index 00000000000..04035358e19
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.js
new file mode 100644
index 00000000000..67a196daf75
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.align.start.rtl.worker.js
@@ -0,0 +1,31 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.align.start.rtl
+// Description:textAlign start with rtl is the right edge
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.direction = 'rtl';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'start';
+ ctx.fillText('DD', 100, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textAlign start with rtl is the right edge");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.html
new file mode 100644
index 00000000000..397a0766bb6
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.js
new file mode 100644
index 00000000000..a0ab72915fd
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.alphabetic.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.baseline.alphabetic
+// Description:
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillText('CC', 0, 37.5);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.html
new file mode 100644
index 00000000000..096ad04905d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.js
new file mode 100644
index 00000000000..e1713888341
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.bottom.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.baseline.bottom
+// Description:textBaseline bottom is the bottom of the em square (not the bounding box)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textBaseline = 'bottom';
+ ctx.fillText('CC', 0, 50);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textBaseline bottom is the bottom of the em square (not the bounding box)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.html
new file mode 100644
index 00000000000..58af509d6c5
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.js
new file mode 100644
index 00000000000..c288ab4c866
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.middle.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.baseline.middle
+// Description:textBaseline middle is the middle of the em square (not the bounding box)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textBaseline = 'middle';
+ ctx.fillText('CC', 0, 25);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textBaseline middle is the middle of the em square (not the bounding box)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.html
new file mode 100644
index 00000000000..7d246b52256
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.js
new file mode 100644
index 00000000000..e7d0b167c02
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.baseline.top.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.baseline.top
+// Description:textBaseline top is the top of the em square (not the bounding box)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textBaseline = 'top';
+ ctx.fillText('CC', 0, 0);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 5,45, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,45, 0,255,0,255, 2);
+}, "textBaseline top is the top of the em square (not the bounding box)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.html
new file mode 100644
index 00000000000..a16f006b216
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.js
new file mode 100644
index 00000000000..a314870f115
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.bound.worker.js
@@ -0,0 +1,27 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.fill.maxWidth.bound
+// Description:fillText handles maxWidth based on line size, not bounding box size
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('DD', 0, 37.5, 100);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "fillText handles maxWidth based on line size, not bounding box size");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.html
new file mode 100644
index 00000000000..6f0d73c531a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.js
new file mode 100644
index 00000000000..e225e703519
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fill.maxWidth.fontface.worker.js
@@ -0,0 +1,27 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.fill.maxWidth.fontface
+// Description:fillText works on @font-face fonts
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#0f0';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#f00';
+ ctx.fillText('EEEE', -50, 37.5, 40);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "fillText works on @font-face fonts");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.html
new file mode 100644
index 00000000000..a75e8a8cc93
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.js
new file mode 100644
index 00000000000..c35c82d71f0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.notinpage.worker.js
@@ -0,0 +1,27 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.fontface.notinpage
+// Description:@font-face fonts should work even if they are not used in the page
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '67px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('AA', 0, 50);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "@font-face fonts should work even if they are not used in the page");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.html
new file mode 100644
index 00000000000..03da1eb8f86
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.js
new file mode 100644
index 00000000000..fb1f7980a6c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.repeat.worker.js
@@ -0,0 +1,30 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.fontface.repeat
+// Description:Draw with the font immediately, then wait a bit until and draw again. (This crashes some version of WebKit.)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.font = '67px CanvasTest';
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('AA', 0, 50);
+
+ await new Promise(resolve => t.step_timeout(resolve, 500));
+ ctx.fillText('AA', 0, 50);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "Draw with the font immediately, then wait a bit until and draw again. (This crashes some version of WebKit.)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.html
new file mode 100644
index 00000000000..387b473d591
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.fontface.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.js
new file mode 100644
index 00000000000..a09a0f88d7e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.fontface.worker.js
@@ -0,0 +1,27 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.fontface
+// Description:
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '67px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('AA', 0, 50);
+ _assertPixelApprox(canvas, 5,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 95,5, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.html
new file mode 100644
index 00000000000..38860593bdf
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.space.basic.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.js
new file mode 100644
index 00000000000..96bd4159c71
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.basic.worker.js
@@ -0,0 +1,25 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.space.basic
+// Description:U+0020 is rendered the correct size (1em wide)
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('E EE', -100, 37.5);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "U+0020 is rendered the correct size (1em wide)");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.html
new file mode 100644
index 00000000000..ec9bf22c4ad
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.js
new file mode 100644
index 00000000000..e9cd9dc8292
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.end.worker.js
@@ -0,0 +1,26 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.space.collapse.end
+// Description:Space characters at the end of a line are NOT collapsed
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.textAlign = 'right';
+ ctx.fillText('EE ', 100, 37.5);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 255,0,0,255, 2);
+}, "Space characters at the end of a line are NOT collapsed");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.html
new file mode 100644
index 00000000000..d75a9cac427
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.js
new file mode 100644
index 00000000000..a37094e28c8
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.nonspace.worker.js
@@ -0,0 +1,25 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.space.collapse.nonspace
+// Description:Non-space characters are not converted to U+0020 and collapsed
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('E\x0b EE', -150, 37.5);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "Non-space characters are not converted to U+0020 and collapsed");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.html
new file mode 100644
index 00000000000..212f5caa665
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.js
new file mode 100644
index 00000000000..1f090cb4262
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.other.worker.js
@@ -0,0 +1,25 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.space.collapse.other
+// Description:Space characters are converted to U+0020, and are NOT collapsed
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('E \x09\x0a\x0c\x0d \x09\x0a\x0c\x0dEE', 0, 37.5);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 255,0,0,255, 2);
+}, "Space characters are converted to U+0020, and are NOT collapsed");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.html
new file mode 100644
index 00000000000..57e56b9a4f1
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.js
new file mode 100644
index 00000000000..02551b7de71
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.space.worker.js
@@ -0,0 +1,25 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.space.collapse.space
+// Description:Space characters are converted to U+0020, and are NOT collapsed
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText('E EE', 0, 37.5);
+ _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 255,0,0,255, 2);
+}, "Space characters are converted to U+0020, and are NOT collapsed");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.html
new file mode 100644
index 00000000000..22b3f425bea
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.js
new file mode 100644
index 00000000000..bd6e523283f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.draw.space.collapse.start.worker.js
@@ -0,0 +1,25 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.draw.space.collapse.start
+// Description:Space characters at the start of a line are NOT collapsed
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ ctx.fillStyle = '#f00';
+ ctx.fillRect(0, 0, 100, 50);
+ ctx.fillStyle = '#0f0';
+ ctx.fillText(' EE', 0, 37.5);
+ _assertPixelApprox(canvas, 25,25, 255,0,0,255, 2);
+ _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2);
+}, "Space characters at the start of a line are NOT collapsed");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.html
new file mode 100644
index 00000000000..9a84741a175
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.emHeights.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.js
new file mode 100644
index 00000000000..163394ff1b2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.emHeights.worker.js
@@ -0,0 +1,28 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.emHeights
+// Description:Testing emHeights
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '40px CanvasTest';
+ ctx.direction = 'ltr';
+ ctx.align = 'left'
+ _assertSame(ctx.measureText('A').emHeightAscent, 30, "ctx.measureText('A').emHeightAscent", "30");
+ _assertSame(ctx.measureText('A').emHeightDescent, 10, "ctx.measureText('A').emHeightDescent", "10");
+ _assertSame(ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent, 40, "ctx.measureText('A').emHeightDescent + ctx.measureText('A').emHeightAscent", "40");
+
+ _assertSame(ctx.measureText('ABCD').emHeightAscent, 30, "ctx.measureText('ABCD').emHeightAscent", "30");
+ _assertSame(ctx.measureText('ABCD').emHeightDescent, 10, "ctx.measureText('ABCD').emHeightDescent", "10");
+ _assertSame(ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent, 40, "ctx.measureText('ABCD').emHeightDescent + ctx.measureText('ABCD').emHeightAscent", "40");
+}, "Testing emHeights");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.html
new file mode 100644
index 00000000000..78775d43171
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.js
new file mode 100644
index 00000000000..6ea01b14963
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-reduced-ascent.worker.js
@@ -0,0 +1,26 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.fontBoundingBox-reduced-ascent
+// Description:Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest-ascent256", "url('/fonts/CanvasTest-ascent256.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '40px CanvasTest-ascent256';
+ ctx.direction = 'ltr';
+ ctx.align = 'left'
+ _assertSame(ctx.measureText('A').fontBoundingBoxAscent, 10, "ctx.measureText('A').fontBoundingBoxAscent", "10");
+ _assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10");
+
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 10, "ctx.measureText('ABCD').fontBoundingBoxAscent", "10");
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10");
+}, "Testing fontBoundingBox for OffscreenCanvas with reduced ascent metric");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.html
new file mode 100644
index 00000000000..f259d039697
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.js
new file mode 100644
index 00000000000..c8175eec3ce
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox-zero-descent.worker.js
@@ -0,0 +1,26 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.fontBoundingBox-zero-descent
+// Description:Testing fontBoundingBox for OffscreenCanvas with zero descent metric
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest-descent0", "url('/fonts/CanvasTest-descent0.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '40px CanvasTest-descent0';
+ ctx.direction = 'ltr';
+ ctx.align = 'left'
+ _assertSame(ctx.measureText('A').fontBoundingBoxAscent, 30, "ctx.measureText('A').fontBoundingBoxAscent", "30");
+ _assertSame(ctx.measureText('A').fontBoundingBoxDescent, 0, "ctx.measureText('A').fontBoundingBoxDescent", "0");
+
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 30, "ctx.measureText('ABCD').fontBoundingBoxAscent", "30");
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 0, "ctx.measureText('ABCD').fontBoundingBoxDescent", "0");
+}, "Testing fontBoundingBox for OffscreenCanvas with zero descent metric");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.html
new file mode 100644
index 00000000000..3fb2cc10fa2
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.js
new file mode 100644
index 00000000000..080a4d45b82
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.ahem.worker.js
@@ -0,0 +1,25 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.fontBoundingBox.ahem
+// Description:Testing fontBoundingBox for font ahem
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("Ahem", "url('/fonts/Ahem.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px Ahem';
+ ctx.direction = 'ltr';
+ ctx.align = 'left'
+ _assertSame(ctx.measureText('A').fontBoundingBoxAscent, 40, "ctx.measureText('A').fontBoundingBoxAscent", "40");
+ _assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10");
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 40, "ctx.measureText('ABCD').fontBoundingBoxAscent", "40");
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10");
+}, "Testing fontBoundingBox for font ahem");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.html
new file mode 100644
index 00000000000..ea6c65de8f7
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.js
new file mode 100644
index 00000000000..5c28b8f6889
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.fontBoundingBox.worker.js
@@ -0,0 +1,26 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.fontBoundingBox
+// Description:Testing fontBoundingBox measurements
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '40px CanvasTest';
+ ctx.direction = 'ltr';
+ ctx.align = 'left'
+ _assertSame(ctx.measureText('A').fontBoundingBoxAscent, 30, "ctx.measureText('A').fontBoundingBoxAscent", "30");
+ _assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10");
+
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 30, "ctx.measureText('ABCD').fontBoundingBoxAscent", "30");
+ _assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10");
+}, "Testing fontBoundingBox measurements");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.html
new file mode 100644
index 00000000000..4d5b311f04e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.width.basic.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.js
new file mode 100644
index 00000000000..f653f20f8e6
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.basic.worker.js
@@ -0,0 +1,25 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.width.basic
+// Description:The width of character is same as font used
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ _assertSame(ctx.measureText('A').width, 50, "ctx.measureText('A').width", "50");
+ _assertSame(ctx.measureText('AA').width, 100, "ctx.measureText('AA').width", "100");
+ _assertSame(ctx.measureText('ABCD').width, 200, "ctx.measureText('ABCD').width", "200");
+
+ ctx.font = '100px CanvasTest';
+ _assertSame(ctx.measureText('A').width, 100, "ctx.measureText('A').width", "100");
+}, "The width of character is same as font used");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.html
new file mode 100644
index 00000000000..eefb6eaec67
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.width.empty.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.js
new file mode 100644
index 00000000000..932b82e129d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.empty.worker.js
@@ -0,0 +1,20 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.width.empty
+// Description:The empty string has zero width
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ _assertSame(ctx.measureText("").width, 0, "ctx.measureText(\"\").width", "0");
+}, "The empty string has zero width");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.html b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.html
new file mode 100644
index 00000000000..01bc09cd3db
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../../../../resources/testharness.js"></script>
+<script src="../../../../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../../../../html/canvas/offscreen/text/2d.text.measure.width.space.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.js b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.js
new file mode 100644
index 00000000000..3f0e6d65dad
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/html/canvas/offscreen/text/2d.text.measure.width.space.worker.js
@@ -0,0 +1,26 @@
+// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
+// OffscreenCanvas test in a worker:2d.text.measure.width.space
+// Description:Space characters are converted to U+0020 and NOT collapsed
+// Note:
+
+importScripts("/resources/testharness.js");
+importScripts("/html/canvas/resources/canvas-tests.js");
+
+promise_test(async t => {
+ var canvas = new OffscreenCanvas(100, 50);
+ var ctx = canvas.getContext('2d');
+
+ var f = new FontFace("CanvasTest", "url('/fonts/CanvasTest.ttf')");
+ f.load();
+ self.fonts.add(f);
+ await self.fonts.ready;
+ ctx.font = '50px CanvasTest';
+ _assertSame(ctx.measureText('A B').width, 150, "ctx.measureText('A B').width", "150");
+ _assertSame(ctx.measureText('A B').width, 200, "ctx.measureText('A B').width", "200");
+ _assertSame(ctx.measureText('A \x09\x0a\x0c\x0d \x09\x0a\x0c\x0dB').width, 650, "ctx.measureText('A \\x09\\x0a\\x0c\\x0d \\x09\\x0a\\x0c\\x0dB').width", "650");
+ _assert(ctx.measureText('A \x0b B').width >= 200, "ctx.measureText('A \\x0b B').width >= 200");
+
+ _assertSame(ctx.measureText(' AB').width, 150, "ctx.measureText(' AB').width", "150");
+ _assertSame(ctx.measureText('AB ').width, 150, "ctx.measureText('AB ').width", "150");
+}, "Space characters are converted to U+0020 and NOT collapsed");
+done();