2
* Copyright 2013 Canonical Ltd.
4
* This file is part of webbrowser-app.
6
* webbrowser-app is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* webbrowser-app is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
function test_get_domain_data() {
27
{url: "http://ubuntu.com", domain: "ubuntu.com"},
28
{url: "http://www.ubuntu.com", domain: "www.ubuntu.com"},
29
{url: "http://ubuntu.com/", domain: "ubuntu.com"},
30
{url: "http://www.ubuntu.com/", domain: "www.ubuntu.com"},
31
{url: "ubuntu.com", domain: "ubuntu.com"},
32
{url: "ubuntu.com/", domain: "ubuntu.com"},
33
{url: "ubuntu.com/phone", domain: "ubuntu.com"},
34
{url: "http://ubuntu.com/phone", domain: "ubuntu.com"},
35
{url: "www.ubuntu.com/phone", domain: "www.ubuntu.com"},
36
{url: "http://ubuntu.com/phone/index.html", domain: "ubuntu.com"},
37
{url: "ubuntu.com/phone/index.html", domain: "ubuntu.com"},
38
{url: "www.ubuntu.com/phone/index.html", domain: "www.ubuntu.com"},
39
{url: "http://ubuntu.com/phone/index.html?foo=bar&baz=bleh", domain: "ubuntu.com"},
42
function test_get_domain(data) {
43
compare(userAgent.getDomain(data.url), data.domain)
46
function test_get_domains_data() {
48
{domain: "ubuntu.com", domains: ["ubuntu.com", "com"]},
49
{domain: "test.example.org", domains: ["test.example.org", "example.org", "org"]},
52
function test_get_domains(data) {
53
compare(userAgent.getDomains(data.domain), data.domains)
56
function test_get_ua_string_data() {
58
{url: "http://ubuntu.com", ua: userAgent.defaultUA},
59
{url: "http://example.org", ua: "full override"},
60
{url: "http://example.com/test", ua: "Mozilla/5.0 (Ubuntu Edge; Mobile) WebKit/537.21"},
61
{url: "http://www.google.com/", ua: "Mozilla/5.0 (Ubuntu; ble) WebKit/537.21"},
62
{url: "https://mail.google.com/", ua: "Mozilla/5.0 (Ubuntu; Touch) WebKit/537.21"},
65
function test_get_ua_string(data) {
66
compare(userAgent.getUAString(data.url), data.ua)
69
readonly property Item userAgent: loader.item
72
source: Qt.resolvedUrl("../../../src/Ubuntu/Components/Extras/Browser/UserAgent01.qml")
74
item.defaultUA = "Mozilla/5.0 (Ubuntu; Mobile) WebKit/537.21"
76
"example.org": "full override",
77
"example.com": ["Ubuntu", "Ubuntu Edge"],
78
"google.com": [/mobi/i, "b"],
79
"mail.google.com": [/mobile/i, "Touch"],