1 | /* |
2 | * Copyright (C) 2013 Igalia S.L. |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Library General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Library General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Library General Public License |
15 | * along with this library; see the file COPYING.LIB. If not, write to |
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | * Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #include "config.h" |
21 | |
22 | #include "WebProcessTest.h" |
23 | #include <webkit2/webkit-web-extension.h> |
24 | |
25 | #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC |
26 | |
27 | class AutocleanupsTest : public WebProcessTest { |
28 | public: |
29 | static std::unique_ptr<WebProcessTest> create() { return std::unique_ptr<WebProcessTest>(new AutocleanupsTest()); } |
30 | |
31 | private: |
32 | bool testWebProcessAutocleanups(WebKitWebPage* webPage) |
33 | { |
34 | // Transfer none |
35 | g_autoptr(WebKitWebPage) page = WEBKIT_WEB_PAGE(g_object_ref(G_OBJECT(webPage))); |
36 | g_assert_true(WEBKIT_IS_WEB_PAGE(page)); |
37 | assertObjectIsDeletedWhenTestFinishes(G_OBJECT(page)); |
38 | |
39 | // Transfer none |
40 | g_autoptr(WebKitDOMDocument) document = WEBKIT_DOM_DOCUMENT(g_object_ref(G_OBJECT(webkit_web_page_get_dom_document(page)))); |
41 | g_assert_true(WEBKIT_DOM_IS_DOCUMENT(document)); |
42 | assertObjectIsDeletedWhenTestFinishes(G_OBJECT(document)); |
43 | |
44 | // Transfer full |
45 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
46 | g_autoptr(WebKitDOMDOMWindow) window = webkit_dom_document_get_default_view(document); |
47 | g_assert_true(WEBKIT_DOM_IS_DOM_WINDOW(window)); |
48 | G_GNUC_END_IGNORE_DEPRECATIONS; |
49 | assertObjectIsDeletedWhenTestFinishes(G_OBJECT(window)); |
50 | |
51 | // Transfer full |
52 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS; |
53 | g_autoptr(WebKitDOMRange) range = webkit_dom_document_create_range(document); |
54 | g_assert_true(WEBKIT_DOM_IS_RANGE(range)); |
55 | G_GNUC_END_IGNORE_DEPRECATIONS; |
56 | assertObjectIsDeletedWhenTestFinishes(G_OBJECT(range)); |
57 | |
58 | return true; |
59 | } |
60 | |
61 | bool runTest(const char* testName, WebKitWebPage* page) override |
62 | { |
63 | if (!strcmp(testName, "web-process-autocleanups" )) |
64 | return testWebProcessAutocleanups(page); |
65 | |
66 | g_assert_not_reached(); |
67 | return false; |
68 | } |
69 | }; |
70 | |
71 | static void __attribute__((constructor)) registerTests() |
72 | { |
73 | REGISTER_TEST(AutocleanupsTest, "Autocleanups/web-process-autocleanups" ); |
74 | } |
75 | |
76 | #endif // G_DEFINE_AUTOPTR_CLEANUP_FUNC |
77 | |