summaryrefslogtreecommitdiffstats
path: root/vendor/url/tests/debugger_visualizer.rs
blob: 4558e07015acaf5034dda755f5918ffb97e1984d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use debugger_test::debugger_test;
use url::Url;

#[inline(never)]
fn __break() {}

#[debugger_test(
    debugger = "cdb",
    commands = "
    .nvlist

    dx base_url

    dx url_with_non_special_scheme

    dx url_with_user_pass_port_query_fragments

    dx url_blob

    dx url_with_base

    dx url_with_base_replaced

    dx url_with_comma",
    expected_statements = r#"
    pattern:debugger_visualizer-.*\.exe \(embedded NatVis ".*-[0-9]+\.natvis"\)

    base_url         : "http://example.org/foo/bar" [Type: url::Url]
    [<Raw View>]     [Type: url::Url]
    [scheme]         : "http"
    [host]           : "example.org"
    [path]           : "/foo/bar"

    url_with_non_special_scheme : "non-special://test/x" [Type: url::Url]
    [<Raw View>]     [Type: url::Url]
    [scheme]         : "non-special"
    [host]           : "test"
    [path]           : "/x"

    url_with_user_pass_port_query_fragments : "http://user:pass@foo:21/bar;par?b#c" [Type: url::Url]
    [<Raw View>]     [Type: url::Url]
    [scheme]         : "http"
    [username]       : "user"
    [host]           : "foo"
    [port]           : 21
    [path]           : "/bar;par"
    [query]          : "b"
    [fragment]       : "c"

    url_blob         : "blob:https://example.com:443/" [Type: url::Url]
    [<Raw View>]     [Type: url::Url]
    [scheme]         : "blob"
    [path]           : "https://example.com:443/"

    url_with_base    : "http://example.org/a%2fc" [Type: url::Url]
    [<Raw View>]     [Type: url::Url]
    [scheme]         : "http"
    [host]           : "example.org"
    [path]           : "/a%2fc"

    url_with_base_replaced : "http://[::7f00:1]/" [Type: url::Url]
    [<Raw View>]     [Type: url::Url]
    [scheme]         : "http"
    [host]           : "[::7f00:1]"
    [path]           : "/"

    url_with_comma   : "data:text/html,test#test" [Type: url::Url]
    [<Raw View>]     [Type: url::Url]
    [scheme]         : "data"
    [path]           : "text/html,test"
    [fragment]       : "test"
    "#
)]
fn test_url_visualizer() {
    // Copied from https://github.com/web-platform-tests/wpt/blob/master/url/
    let base_url = Url::parse("http://example.org/foo/bar").unwrap();
    assert_eq!(base_url.as_str(), "http://example.org/foo/bar");

    let url_with_non_special_scheme = Url::parse("non-special://:@test/x").unwrap();
    assert_eq!(url_with_non_special_scheme.as_str(), "non-special://test/x");

    let url_with_user_pass_port_query_fragments =
        Url::parse("http://user:pass@foo:21/bar;par?b#c").unwrap();
    assert_eq!(
        url_with_user_pass_port_query_fragments.as_str(),
        "http://user:pass@foo:21/bar;par?b#c"
    );

    let url_blob = Url::parse("blob:https://example.com:443/").unwrap();
    assert_eq!(url_blob.as_str(), "blob:https://example.com:443/");

    let url_with_base = base_url.join("/a%2fc").unwrap();
    assert_eq!(url_with_base.as_str(), "http://example.org/a%2fc");

    let url_with_base_replaced = base_url.join("http://[::127.0.0.1]").unwrap();
    assert_eq!(url_with_base_replaced.as_str(), "http://[::7f00:1]/");

    let url_with_comma = base_url.join("data:text/html,test#test").unwrap();
    assert_eq!(url_with_comma.as_str(), "data:text/html,test#test");

    __break();
}