// The live web page a record's web column opens: held to http or https with a// host wherever it meets an address, and plain words when it did not load.// Every address is invented.importCottonKitimportCottonValuesimportFoundationimport XCTest@testable importCottonUI@MainActorfinalclassReaderNoLossTests: XCTestCase {privatestaticvar resources: Bundle? {Bundle(url: SourceSweep.iosSources.appendingPathComponent("CottonUI/Resources")) }privatefunc note() throws -> TableDefinition {let loaded = FixtureDefinitions.load(from: try XCTUnwrap(Self.resources))returntry XCTUnwrap(loaded.definitions.first { $0.id == "note" }) }privatefunc page(_ values: [String: RecordValue]) -> TableRecord {TableRecord(id: "example-page", values: ["url": .text("https://example.com/a")].merging(values) { $1 }) }/// RULE: Every address the live page meets is held to http or https with a host — the saved one, a popup, a page it follows in its own window, and where it reports it has landed (what "Open in browser" hands the system) — and a navigation it refused is no failure.func testTheLivePageNeverLeavesTheWeb() throws { XCTAssertEqual(TableDefinition.webLink(URL(string: "https://example.com/a"))?.host, "example.com")for refused in ["mailto:someone@example.com", "itms-apps://example.com/app", "javascript:void(0)","about:blank", "file:///tmp/x", "data:text/html,hi"] { XCTAssertNil(TableDefinition.webLink(URL(string: refused)), refused) } XCTAssertNil(TableDefinition.webLink(nil)) }}