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