weitsai / domsnitch

Automatically exported from code.google.com/p/domsnitch
Apache License 2.0
0 stars 0 forks source link

Setting document.cookie on top level causes error in DOMSnitch.Modules.Document.prototype.generateGlobalId #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Make a page that sets document.cookie on the top level during page load 
script parsing and execution.
2. Turn on all DOMSnitch modules
3. Reload page

What is the expected output? What do you see instead?

An error occurs in line 66 of an unknown JS file.  Code is as follows:

DOMSnitch.Modules.Document.prototype.generateGlobalId = function(type) {
  // Generate unique, yet reproducible global ID
  var caller = arguments.callee.caller.caller.toString(); // line 66
  var token = caller.length > 50 ? caller.substring(0, 50) : caller;

  var baseUrl = document.location.origin + document.location.pathname + "#";
  var gid = baseUrl + type + "/" + token.replace(/\s/gg, "") + "-" + caller.length;

  return gid;
}

arguments.callee.caller ends up referencing the top level function, so 
arguments.callee.caller.caller is null.  I suspect code needs to be added to 
account for this edge case and generate a unique ID ("null" would probably be 
sufficient).

What version of the product are you using? On what operating system?

I downloaded the latest CRX download.  Version 0.706

Please provide any additional information below.

Google Chrome   14.0.798.0 (Official Build 89770) canary
OS  Windows
WebKit  535.1 (trunk@89232)
JavaScript  V8 3.4.4
Flash   10,3,181,26
User Agent  Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) 
Chrome/14.0.798.0 Safari/535.1
Command Line    "C:\Documents and Settings\dbugglin\Local Settings\Application 
Data\Google\Chrome SxS\Application\chrome.exe" --allow-file-access-from-files 
--disable-flash-sandbox --enable-timeline-extension-api 
--remote-debugging-port=1337 --flag-switches-begin --enable-click-to-play 
--enable-compact-navigation --conflicting-modules-check 
--enable-crxless-web-apps --no-pings --disable-interactive-form-validation 
--enable-nacl --experimental-location-features 
--enable-experimental-extension-apis --focus-existing-tab-on-open 
--ignore-gpu-blacklist --indexeddb-use-leveldb --multi-profiles 
--new-tab-page-4 --enable-p2papi --ppapi-flash-in-process 
--preload-instant-search --enable-remoting --enable-tab-groups-context-menu 
--enable-vertical-tabs --enable-webaudio --flag-switches-end
Executable Path C:\Documents and Settings\dbugglin\Local Settings\Application 
Data\Google\Chrome SxS\Application\chrome.exe
Profile Path    C:\Documents and Settings\dbugglin\Local Settings\Application 
Data\Google\Chrome SxS\User Data\Default

Original issue reported on code.google.com by megazzt on 22 Jun 2011 at 2:50

GoogleCodeExporter commented 9 years ago
Correction: "arguments.callee.caller ends up referencing the top level 
function, so arguments.callee.caller.caller is null." this is incorrect, ignore.

arguments.callee.caller.caller is probably normally a correct reference but it 
seems to be null when it should point to the top level.  Firefox, Chrome, and 
IE all do it this way (Firefox returns undefined) so I suspect this is correct 
behavior on the part of Chrome.

Original comment by megazzt on 22 Jun 2011 at 2:55

GoogleCodeExporter commented 9 years ago

Original comment by r...@google.com on 6 Jul 2011 at 2:22

GoogleCodeExporter commented 9 years ago
This should be fixed in 0.717. Please comment if you see otherwise.

Original comment by r...@r-n-d.org on 1 Sep 2011 at 8:06