Bug 119472 - REGRESSION (r153106-r153334): Function.prototype.call() and .apply() in web worker can’t set ‘this’ to global object
Summary: REGRESSION (r153106-r153334): Function.prototype.call() and .apply() in web w...
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.8
: P2 Normal
Assignee: Nobody
URL: https://dl.dropboxusercontent.com/u/3...
Depends on:
Reported: 2013-08-03 14:49 PDT by teeb
Modified: 2016-08-01 07:32 PDT (History)
2 users (show)

See Also:

test cases to reproduce bug (19.42 KB, application/zip)
2013-08-03 14:49 PDT, teeb
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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()

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');
    postMessage('"this" is correctly defined to the worker global');