Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#3822 closed defect (fixed)

jsHydra breaks strict-mode

Reported by: sebastian Assignee: sebastian
Priority: P3 Milestone: Adblock-Plus-1.12-for-Chrome-Opera-Safari
Module: Automation Keywords:
Cc: Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29338486

Description

Observed behaviour

jsHydra, when using --arg module=true, wraps the code into a Common JS module. Therefore it has to initialize the exports variable before inserting the original code. However, in order to enable strict mode "use strict" must be the first token in the function. Currently, a module generated from a file using strict mode looks like that:

require.scopes["module"] = (function()
{
  var exports = {};
  "use strict";
  ...
  return exports;
})();

But as "use strict" isn't the first token, strict mode won't actually be enabled.

Expected behaviour

jsHydra should insert var exports = {}; after "use strict" if given at the beginning of the source file, in order to preserve strict-mode.

Change History (6)

comment:1 Changed 4 years ago by sebastian

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed 4 years ago by abpbot

A commit referencing this issue has landed:
https://hg.adblockplus.org/jshydra/rev/91d258341fa8

comment:3 Changed 4 years ago by abpbot

A commit referencing this issue has landed:
https://hg.adblockplus.org/buildtools/rev/cf407fe581d0

comment:4 Changed 4 years ago by abpbot

A commit referencing this issue has landed:
https://hg.adblockplus.org/adblockpluschrome/rev/b1638c2d8f12

comment:5 Changed 4 years ago by sebastian

  • Milestone set to Adblock-Plus-for-Chrome-Opera-Safari-next
  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:6 Changed 4 years ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Checked this via confirming the .js files in the build have "use strict" at the top of the files (under the comment header).

ABP 1.11.0.1606

Note: See TracTickets for help on using tickets.