WebContent: Serialize the document element's outer HTML for WebDriver
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run

This commit is contained in:
Timothy Flynn 2024-11-06 18:45:04 -05:00 committed by Tim Flynn
parent 7b64942fe2
commit ad1ba30b27
Notes: github-actions[bot] 2024-11-07 01:45:12 +00:00

View file

@ -2032,19 +2032,22 @@ Web::WebDriver::Response WebDriverConnection::element_send_keys_impl(String cons
// 13.1 Get Page Source, https://w3c.github.io/webdriver/#dfn-get-page-source
Messages::WebDriverClient::GetSourceResponse WebDriverConnection::get_source()
{
// 1. If the current browsing context is no longer open, return error with error code no such window.
// 1. If session's current browsing context is no longer open, return error with error code no such window.
TRY(ensure_current_browsing_context_is_open());
// 2. Handle any user prompts and return its value if it is an error.
// 2. Try to handle any user prompts with session.
handle_any_user_prompts([this]() {
auto* document = current_browsing_context().active_document();
Optional<String> source;
// 3. Let source be the result of invoking the fragment serializing algorithm on a fictional node whose only child is the document element providing true for the require well-formed flag. If this causes an exception to be thrown, let source be null.
if (auto result = document->serialize_fragment(Web::DOMParsing::RequireWellFormed::Yes); !result.is_error())
// 3. Let source be the result of invoking the fragment serializing algorithm on a fictional node whose only
// child is the document element providing true for the require well-formed flag. If this causes an exception
// to be thrown, let source be null.
if (auto result = document->document_element()->serialize_fragment(Web::DOMParsing::RequireWellFormed::Yes, Web::DOM::FragmentSerializationMode::Outer); !result.is_error())
source = result.release_value();
// 4. Let source be the result of serializing to string the current browsing context active document, if source is null.
// 4. Let source be the result of serializing to string session's current browsing context's active document,
// if source is null.
if (!source.has_value())
source = MUST(document->serialize_fragment(Web::DOMParsing::RequireWellFormed::No));