Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.1

0.6.1 / src / webview / tests_webview_loading.lucb

#==============================================================================================
#
#   tests_webview_loading - a view loads pages and reports them
#
#   DESCRIPTION:
#       A view loads a file and reports the load (started, finished), the URL and the document's
#       title, and presents a frame; the address field's text is sanitized as LibWebView does.
#
#       Copyright (c) 2026 the luce-browser authors.
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

test "a view loads a file: the URL, the title, the load events and a frame":
    test_webview_platform()
    let allocator: memory.Allocator = webview_heap()
    with allocator:
        let view = test_webview_open()
        defer webview_destroy(view)
        var log = TestWebViewLog()
        webview_load(view, test_webview_file_url("first.html"))
        test_webview_wait_for_load(view, &log, "first.html")
        assert(log.load_started >= 1 and log.load_finished >= 1, "the load started and finished")
        assert(test_webview_url_ends_with(view, "/tests/webview/first.html"), "the URL is the file's")
        let title = test_webview_title(view)
        assert(ak.string_eq_string_view(&title, ak.sv("First page")), "the title is the document's")
        assert(log.title_changed >= 1, "the title change was reported")
        assert(webview_has_frame(view), "a frame was presented")
        let size = webview_frame_size(view)
        assert(size.m_width == 800 and size.m_height == 600, "the frame covers the viewport")
        # The link's box is blue at its top left.
        assert(test_webview_pixel(view, 5, 5) == 0x0000ffff, "the link's background is painted")