@@ -46,4 +46,119 @@ public void function_toString() throws Exception {
4646
4747 loadPageVerifyTitle2 (html );
4848 }
49+
50+ /**
51+ * @throws Exception if the test fails
52+ */
53+ @ Test
54+ @ Alerts ("true" )
55+ public void symbolHasInstance () throws Exception {
56+ final String html = DOCTYPE_HTML
57+ + "<html><head>\n "
58+ + "<script>\n "
59+ + LOG_TITLE_FUNCTION
60+ + "function test() {\n "
61+ + " log(Function.prototype.toString instanceof Function);\n "
62+ + "}\n "
63+ + "</script></head><body onload='test()'>\n "
64+ + "</body></html>" ;
65+
66+ loadPageVerifyTitle2 (html );
67+ }
68+
69+ /**
70+ * @throws Exception if the test fails
71+ */
72+ @ Test
73+ @ Alerts ({"[object Function]" , "[object Function]" , "[object Function]" })
74+ public void symbolToStringTag () throws Exception {
75+ final String html = DOCTYPE_HTML
76+ + "<html><head>\n "
77+ + "<script>\n "
78+ + LOG_TITLE_FUNCTION
79+ + "function test() {\n "
80+ + " var toString = Object.prototype.toString;\n "
81+ + " log(toString.call(Function.prototype.toString));\n "
82+ + " log(toString.call(Object.prototype.toString));\n "
83+ + " log(toString.call(Array.prototype.toString));\n "
84+ + "}\n "
85+ + "</script></head><body onload='test()'>\n "
86+ + "</body></html>" ;
87+
88+ loadPageVerifyTitle2 (html );
89+ }
90+
91+ /**
92+ * @throws Exception if the test fails
93+ */
94+ @ Test
95+ @ Alerts ({"undefined" , "undefined" , "false" , "false" })
96+ public void symbolPropertyAccess () throws Exception {
97+ final String html = DOCTYPE_HTML
98+ + "<html><head>\n "
99+ + "<script>\n "
100+ + LOG_TITLE_FUNCTION
101+ + "function test() {\n "
102+ + " var fn = Function.prototype.toString;\n "
103+ + " log(fn[Symbol.toStringTag]);\n "
104+ + " log(fn[Symbol.toPrimitive]);\n "
105+ + " log(Symbol.toStringTag in fn);\n "
106+ + " log(Symbol.toPrimitive in fn);\n "
107+ + "}\n "
108+ + "</script></head><body onload='test()'>\n "
109+ + "</body></html>" ;
110+
111+ loadPageVerifyTitle2 (html );
112+ }
113+
114+ /**
115+ * @throws Exception if the test fails
116+ */
117+ @ Test
118+ @ Alerts ({"undefined" , "hello" , "true" })
119+ public void symbolPropertyWriteRead () throws Exception {
120+ final String html = DOCTYPE_HTML
121+ + "<html><head>\n "
122+ + "<script>\n "
123+ + LOG_TITLE_FUNCTION
124+ + "function test() {\n "
125+ + " var fn = Function.prototype.toString;\n "
126+ + " var sym = Symbol('test');\n "
127+ + " log(fn[sym]);\n "
128+ + " fn[sym] = 'hello';\n "
129+ + " log(fn[sym]);\n "
130+ + " log(sym in fn);\n "
131+ + "}\n "
132+ + "</script></head><body onload='test()'>\n "
133+ + "</body></html>" ;
134+
135+ loadPageVerifyTitle2 (html );
136+ }
137+
138+ /**
139+ * @throws Exception if the test fails
140+ */
141+ @ Test
142+ @ Alerts ({"hello" , "true" , "undefined" , "false" })
143+ public void symbolPropertyDelete () throws Exception {
144+ final String html = DOCTYPE_HTML
145+ + "<html><head>\n "
146+ + "<script>\n "
147+ + LOG_TITLE_FUNCTION
148+ + "function test() {\n "
149+ + " var fn = Function.prototype.toString;\n "
150+ + " var sym = Symbol('del');\n "
151+ + " fn[sym] = 'hello';\n "
152+ + " log(fn[sym]);\n "
153+ + " log(sym in fn);\n "
154+ + " delete fn[sym];\n "
155+ + " log(fn[sym]);\n "
156+ + " log(sym in fn);\n "
157+ + "}\n "
158+ + "</script></head><body onload='test()'>\n "
159+ + "</body></html>" ;
160+
161+ loadPageVerifyTitle2 (html );
162+ }
163+
49164}
0 commit comments