1 /*
2 * Copyright (c) 2002-2025 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.javascript.host;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.annotation.Alerts;
19 import org.htmlunit.junit.annotation.HtmlUnitNYI;
20 import org.junit.jupiter.api.Test;
21
22 /**
23 * Tests for {@link InstallTrigger}.
24 *
25 * @author Ronald Brill
26 */
27 public class InstallTriggerTest extends WebDriverTestCase {
28
29 /**
30 * Strange but this is the reality for browsers.
31 * Because there will be still some sites using this for browser detection the property is
32 * set to null.
33 * https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browsers
34 * https://bugzilla.mozilla.org/show_bug.cgi?id=1442035
35 * @throws Exception if an error occurs
36 */
37 @Test
38 @Alerts(DEFAULT = "undefined",
39 FF = {"null", "object", "{\"enumerable\":true,\"configurable\":true}"},
40 FF_ESR = {"null", "object", "{\"enumerable\":true,\"configurable\":true}"})
41 @HtmlUnitNYI(
42 FF = {"null", "object", "{\"value\":null,\"writable\":true,\"enumerable\":true,\"configurable\":true}"},
43 FF_ESR = {"null", "object", "{\"value\":null,\"writable\":true,\"enumerable\":true,\"configurable\":true}"})
44 public void windowProperty() throws Exception {
45 final String html = DOCTYPE_HTML
46 + "<html><head>\n"
47 + "<script>\n"
48 + LOG_TITLE_FUNCTION
49 + " function test() {\n"
50 + " log(window.InstallTrigger);\n"
51 + " if (typeof InstallTrigger !== 'undefined') {\n"
52 + " log(typeof InstallTrigger);\n"
53 + " log(JSON.stringify(Object.getOwnPropertyDescriptor(window, 'InstallTrigger')));\n"
54 + " }\n"
55 + " }\n"
56 + "</script>\n"
57 + "</head><body onload='test()'>\n"
58 + "</body></html>";
59
60 loadPageVerifyTitle2(html);
61 }
62 }