Bug 119472

Summary: REGRESSION (r153106-r153334): Function.prototype.call() and .apply() in web worker can’t set ‘this’ to global object
Product: WebKit Reporter: teeb <flakes>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: UNCONFIRMED ---    
Severity: Normal CC: guybedford, msaboff
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.8   
URL: https://dl.dropboxusercontent.com/u/3736046/test/webworker-call-apply-global/index.html
Attachments:
Description Flags
test cases to reproduce bug none

Description teeb 2013-08-03 14:49:00 PDT
Created attachment 208073 [details]
test cases to reproduce bug

'use strict'
// out here, ‘this’ references the global object
(function() {
    // in here, ‘this’ is undefined despite being given as first argument to .call()
}).call(this);

Steps to reproduce:
1. Load attached test page, also available at https://dl.dropboxusercontent.com/u/3736046/test/webworker-call-apply-global/index.html
2. Note that ’typeof this’ in test cases is “undefined” in WebKit nightlies since r153334.

Expected behavior:
’this’ inside the functions should presumably be set to the web worker global object, like it is in all other tested browsers (release Safari, Firefox, Chrome, Chrome Canary).

FWIW, this only seems to happen in strict mode scopes.
Comment 1 teeb 2014-01-29 13:32:47 PST
Still happening as of r163011.
Comment 2 Alexey Proskuryakov 2014-03-28 19:17:38 PDT
Was this fixed in bug 130553 and bug 130554?
Comment 3 Michael Saboff 2014-03-28 21:48:24 PDT
(In reply to comment #2)
> Was this fixed in bug 130553 and bug 130554?

I believe it was.  130554 specifically fixed that we can access "this" in strict mode.  Is there a test that needs to be reenabled or can we just close this out?
Comment 4 Guy Bedford 2016-08-01 07:32:53 PDT
I can confirm this is working in the latest nightly against the simple test case in a worker:

function a() {
  "use strict";
  if (typeof this == 'undefined')
    postMessage('"this" is undefined, when it should be the worker global');
  else
    postMessage('"this" is correctly defined to the worker global');
}

a.call(self);