@@ -175,4 +175,110 @@ public void conditionallyCreatedFunctionStrict() throws Exception {
175175
176176 loadPageVerifyTitle2 (html );
177177 }
178+
179+ /**
180+ * @throws Exception if the test fails
181+ */
182+ @ Test
183+ @ Alerts ("Hello!" )
184+ public void applyThisFromBoundArgs () throws Exception {
185+ final String html = DOCTYPE_HTML
186+ + "<html><head></head>\n "
187+ + "<body>\n "
188+ + "<script>\n "
189+ + " 'use strict';\n "
190+ + LOG_TITLE_FUNCTION
191+ + " var f = function(x) { return this.toString(); };\n "
192+ + " var a = f.apply;\n "
193+ + " var b = a.bind(f, 'Hello!');\n "
194+ + " log(b([1,2]));\n "
195+ + "</script>\n "
196+ + "</body></html>" ;
197+
198+ loadPageVerifyTitle2 (html );
199+ }
200+
201+ /**
202+ * @throws Exception if the test fails
203+ */
204+ @ Test
205+ @ Alerts ("Hello!" )
206+ public void applyToApplyCallsCorrectFunction () throws Exception {
207+ final String html = DOCTYPE_HTML
208+ + "<html><head></head>\n "
209+ + "<body>\n "
210+ + "<script>\n "
211+ + " 'use strict';\n "
212+ + LOG_TITLE_FUNCTION
213+ + " function foo(x) {return x;};\n "
214+ + " var r = Function.prototype.apply.apply(foo, ['b', ['Hello!', 'Goodbye!']]);\n "
215+ + " log(r);\n "
216+ + "</script>\n "
217+ + "</body></html>" ;
218+
219+ loadPageVerifyTitle2 (html );
220+ }
221+
222+ /**
223+ * @throws Exception if the test fails
224+ */
225+ @ Test
226+ @ Alerts ("b" )
227+ public void applyToApplySetsCorrectFunctionThis () throws Exception {
228+ final String html = DOCTYPE_HTML
229+ + "<html><head></head>\n "
230+ + "<body>\n "
231+ + "<script>\n "
232+ + " 'use strict';\n "
233+ + LOG_TITLE_FUNCTION
234+ + " function foo(x) {return this.toString();};\n "
235+ + " var r = Function.prototype.apply.apply(foo, ['b', ['Hello!', 'Goodbye!']]);\n "
236+ + " log(r);\n "
237+ + "</script>\n "
238+ + "</body></html>" ;
239+
240+ loadPageVerifyTitle2 (html );
241+ }
242+
243+ /**
244+ * @throws Exception if the test fails
245+ */
246+ @ Test
247+ @ Alerts ("Hello!" )
248+ public void applyToCallCallsCorrectFunction () throws Exception {
249+ final String html = DOCTYPE_HTML
250+ + "<html><head></head>\n "
251+ + "<body>\n "
252+ + "<script>\n "
253+ + " 'use strict';\n "
254+ + LOG_TITLE_FUNCTION
255+ + " function foo(x) {return x;};\n "
256+ + " var r = foo.call.apply(foo, ['b', 'Hello!']);\n "
257+ + " log(r);\n "
258+ + "</script>\n "
259+ + "</body></html>" ;
260+
261+ loadPageVerifyTitle2 (html );
262+ }
263+
264+ /**
265+ * @throws Exception if the test fails
266+ */
267+ @ Test
268+ @ Alerts ("b" )
269+ public void applyToCallSetsCorrectFunctionThis () throws Exception {
270+ final String html = DOCTYPE_HTML
271+ + "<html><head></head>\n "
272+ + "<body>\n "
273+ + "<script>\n "
274+ + " 'use strict';\n "
275+ + LOG_TITLE_FUNCTION
276+ + " function foo(x) {return this.toString();};\n "
277+ + " var r = foo.call.apply(foo, ['b', 'Hello!']);\n "
278+ + " log(r);\n "
279+ + "</script>\n "
280+ + "</body></html>" ;
281+
282+ loadPageVerifyTitle2 (html );
283+ }
178284}
0 commit comments