@@ -281,4 +281,71 @@ public void applyToCallSetsCorrectFunctionThis() throws Exception {
281281
282282 loadPageVerifyTitle2 (html );
283283 }
284+
285+ /**
286+ * @throws Exception if the test fails
287+ */
288+ @ Test
289+ @ Alerts ("abcd / undefined" )
290+ public void boundWithoutArgs () throws Exception {
291+ final String html = DOCTYPE_HTML
292+ + "<html><head></head>\n "
293+ + "<body>\n "
294+ + "<script>\n "
295+ + LOG_TITLE_FUNCTION
296+ + " function foo(x) { return this.toString() + ' / ' + x; };\n "
297+ + " var boundThis = 'abcd';\n "
298+ + " var boundFoo = Function.prototype.bind.call(foo, boundThis);\n "
299+ + " var r = boundFoo.call('Hello!');\n "
300+ + " log(r);\n "
301+ + "</script>\n "
302+ + "</body></html>" ;
303+
304+ loadPageVerifyTitle2 (html );
305+ }
306+
307+ /**
308+ * @throws Exception if the test fails
309+ */
310+ @ Test
311+ @ Alerts ("abcd / world" )
312+ public void boundWithArg () throws Exception {
313+ final String html = DOCTYPE_HTML
314+ + "<html><head></head>\n "
315+ + "<body>\n "
316+ + "<script>\n "
317+ + LOG_TITLE_FUNCTION
318+ + " function foo(x) { return this.toString() + ' / ' + x; };\n "
319+ + " var boundThis = 'abcd';\n "
320+ + " var boundFoo = Function.prototype.bind.call(foo, boundThis, 'world');\n "
321+ + " var r = boundFoo.call('Hello!');\n "
322+ + " log(r);\n "
323+ + "</script>\n "
324+ + "</body></html>" ;
325+
326+ loadPageVerifyTitle2 (html );
327+ }
328+
329+
330+ /**
331+ * @throws Exception if the test fails
332+ */
333+ @ Test
334+ @ Alerts ("world" )
335+ public void bound () throws Exception {
336+ final String html = DOCTYPE_HTML
337+ + "<html><head></head>\n "
338+ + "<body>\n "
339+ + "<script>\n "
340+ + LOG_TITLE_FUNCTION
341+ + " function foo() { return 'world'; };\n "
342+ + " var boundThis = 'abcd';\n "
343+ + " var boundFoo = Function.prototype.bind.call(foo, boundThis);\n "
344+ + " var r = boundFoo.call(' dd');\n "
345+ + " log(r);\n "
346+ + "</script>\n "
347+ + "</body></html>" ;
348+
349+ loadPageVerifyTitle2 (html );
350+ }
284351}
0 commit comments