|
6 | 6 | * SPDX-License-Identifier: BSD-2-Clause
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -#include <AK/Base64.h> |
10 | 9 | #include <AK/QuickSort.h>
|
11 | 10 | #include <AK/String.h>
|
12 | 11 | #include <AK/Utf8View.h>
|
|
27 | 26 | #include <LibWeb/HTML/Scripting/ExceptionReporter.h>
|
28 | 27 | #include <LibWeb/HTML/Scripting/Fetching.h>
|
29 | 28 | #include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
30 |
| -#include <LibWeb/HTML/StructuredSerialize.h> |
31 |
| -#include <LibWeb/HTML/StructuredSerializeOptions.h> |
32 | 29 | #include <LibWeb/HTML/Timer.h>
|
33 | 30 | #include <LibWeb/HTML/Window.h>
|
34 | 31 | #include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
|
@@ -108,62 +105,6 @@ bool WindowOrWorkerGlobalScopeMixin::cross_origin_isolated() const
|
108 | 105 | return relevant_settings_object(this_impl()).cross_origin_isolated_capability() == CanUseCrossOriginIsolatedAPIs::Yes;
|
109 | 106 | }
|
110 | 107 |
|
111 |
| -// https://html.spec.whatwg.org/multipage/webappapis.html#dom-btoa |
112 |
| -WebIDL::ExceptionOr<String> WindowOrWorkerGlobalScopeMixin::btoa(String const& data) const |
113 |
| -{ |
114 |
| - auto& vm = this_impl().vm(); |
115 |
| - auto& realm = *vm.current_realm(); |
116 |
| - |
117 |
| - // The btoa(data) method must throw an "InvalidCharacterError" DOMException if data contains any character whose code point is greater than U+00FF. |
118 |
| - Vector<u8> byte_string; |
119 |
| - byte_string.ensure_capacity(data.bytes().size()); |
120 |
| - for (u32 code_point : Utf8View(data)) { |
121 |
| - if (code_point > 0xff) |
122 |
| - return WebIDL::InvalidCharacterError::create(realm, "Data contains characters outside the range U+0000 and U+00FF"_string); |
123 |
| - byte_string.append(code_point); |
124 |
| - } |
125 |
| - |
126 |
| - // Otherwise, the user agent must convert data to a byte sequence whose nth byte is the eight-bit representation of the nth code point of data, |
127 |
| - // and then must apply forgiving-base64 encode to that byte sequence and return the result. |
128 |
| - return TRY_OR_THROW_OOM(vm, encode_base64(byte_string.span())); |
129 |
| -} |
130 |
| - |
131 |
| -// https://html.spec.whatwg.org/multipage/webappapis.html#dom-atob |
132 |
| -WebIDL::ExceptionOr<String> WindowOrWorkerGlobalScopeMixin::atob(String const& data) const |
133 |
| -{ |
134 |
| - auto& vm = this_impl().vm(); |
135 |
| - auto& realm = *vm.current_realm(); |
136 |
| - |
137 |
| - // 1. Let decodedData be the result of running forgiving-base64 decode on data. |
138 |
| - auto decoded_data = decode_base64(data); |
139 |
| - |
140 |
| - // 2. If decodedData is failure, then throw an "InvalidCharacterError" DOMException. |
141 |
| - if (decoded_data.is_error()) |
142 |
| - return WebIDL::InvalidCharacterError::create(realm, "Input string is not valid base64 data"_string); |
143 |
| - |
144 |
| - // 3. Return decodedData. |
145 |
| - // decode_base64() returns a byte buffer. LibJS uses UTF-8 for strings. Use isomorphic decoding to convert bytes to UTF-8. |
146 |
| - return Infra::isomorphic_decode(decoded_data.value()); |
147 |
| -} |
148 |
| - |
149 |
| -// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-queuemicrotask |
150 |
| -void WindowOrWorkerGlobalScopeMixin::queue_microtask(WebIDL::CallbackType& callback) |
151 |
| -{ |
152 |
| - auto& vm = this_impl().vm(); |
153 |
| - auto& realm = *vm.current_realm(); |
154 |
| - |
155 |
| - JS::GCPtr<DOM::Document> document; |
156 |
| - if (is<Window>(this_impl())) |
157 |
| - document = &static_cast<Window&>(this_impl()).associated_document(); |
158 |
| - |
159 |
| - // The queueMicrotask(callback) method must queue a microtask to invoke callback, and if callback throws an exception, report the exception. |
160 |
| - HTML::queue_a_microtask(document, JS::create_heap_function(realm.heap(), [&callback, &realm] { |
161 |
| - auto result = WebIDL::invoke_callback(callback, {}); |
162 |
| - if (result.is_error()) |
163 |
| - HTML::report_exception(result, realm); |
164 |
| - })); |
165 |
| -} |
166 |
| - |
167 | 108 | // https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-createimagebitmap
|
168 | 109 | JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::create_image_bitmap(ImageBitmapSource image, Optional<ImageBitmapOptions> options) const
|
169 | 110 | {
|
@@ -261,24 +202,6 @@ JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::create_image_b
|
261 | 202 | return p;
|
262 | 203 | }
|
263 | 204 |
|
264 |
| -// https://html.spec.whatwg.org/multipage/structured-data.html#dom-structuredclone |
265 |
| -WebIDL::ExceptionOr<JS::Value> WindowOrWorkerGlobalScopeMixin::structured_clone(JS::Value value, StructuredSerializeOptions const& options) const |
266 |
| -{ |
267 |
| - auto& vm = this_impl().vm(); |
268 |
| - (void)options; |
269 |
| - |
270 |
| - // 1. Let serialized be ? StructuredSerializeWithTransfer(value, options["transfer"]). |
271 |
| - // FIXME: Use WithTransfer variant of the AO |
272 |
| - auto serialized = TRY(structured_serialize(vm, value)); |
273 |
| - |
274 |
| - // 2. Let deserializeRecord be ? StructuredDeserializeWithTransfer(serialized, this's relevant realm). |
275 |
| - // FIXME: Use WithTransfer variant of the AO |
276 |
| - auto deserialized = TRY(structured_deserialize(vm, serialized, relevant_realm(this_impl()), {})); |
277 |
| - |
278 |
| - // 3. Return deserializeRecord.[[Deserialized]]. |
279 |
| - return deserialized; |
280 |
| -} |
281 |
| - |
282 | 205 | JS::NonnullGCPtr<WebIDL::Promise> WindowOrWorkerGlobalScopeMixin::fetch(Fetch::RequestInfo const& input, Fetch::RequestInit const& init) const
|
283 | 206 | {
|
284 | 207 | auto& vm = this_impl().vm();
|
|
0 commit comments