View Javadoc
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 Netscape}.
24   *
25   * @author Marc Guillemot
26   * @author Frank Danek
27   * @author Ronald Brill
28   */
29  public class NetscapeTest extends WebDriverTestCase {
30  
31      /**
32       * @throws Exception if the test fails
33       */
34      @Test
35      @Alerts(DEFAULT = {"undefined", "undefined", "TypeError"},
36              FF = {"[object Object]", "undefined", "[object Object]", "undefined"},
37              FF_ESR = {"[object Object]", "undefined", "[object Object]", "undefined"})
38      public void netscape() throws Exception {
39          final String html = DOCTYPE_HTML
40              + "<html><body>\n"
41              + "<script>\n"
42              + LOG_TITLE_FUNCTION
43              + "try {\n"
44              + "  log(window.netscape);\n"
45              + "  log(window.Netscape);\n"
46              + "  log(window.netscape.security);\n"
47              + "  log(window.netscape.security.PrivilegeManager);\n"
48              + "} catch(e) { logEx(e); }\n"
49              + "</script></body></html>";
50  
51          loadPageVerifyTitle2(html);
52      }
53  
54  
55      /**
56       * @throws Exception if the test fails
57       */
58      @Test
59      @Alerts(DEFAULT = "TypeError",
60              FF = {"true", "false", "true"},
61              FF_ESR = {"true", "false", "true"})
62      @HtmlUnitNYI(FF = {"undefined", "true", "true"},
63              FF_ESR = {"undefined", "true", "true"})
64      public void netscapeDescriptor() throws Exception {
65          final String html = DOCTYPE_HTML
66              + "<html><body>\n"
67              + "<script>\n"
68              + LOG_TITLE_FUNCTION
69              + "try {\n"
70              + "  var d1 = Object.getOwnPropertyDescriptor(window, 'netscape');\n"
71              + "  log(d1.writable);\n"
72              + "  log(d1.enumerable);\n"
73              + "  log(d1.configurable);\n"
74              + "} catch(e) { logEx(e); }\n"
75              + "</script></body></html>";
76  
77          loadPageVerifyTitle2(html);
78      }
79  }