Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: safari/ext/background.js

Issue 5721433737003008: Issue 1985 - Replaced __proto__ with Object.create() and Object.getPrototypeOf() (Closed)
Patch Set: Created Feb. 11, 2015, 11:51 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « qunit/common.js ('k') | safari/ext/common.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function() 18 (function()
19 { 19 {
20 /* Pages */ 20 /* Pages */
21 21
22 var pages = {__proto__: null}; 22 var pages = Object.create(null);
23 var pageCounter = 0; 23 var pageCounter = 0;
24 24
25 var Page = function(id, tab, url) 25 var Page = function(id, tab, url)
26 { 26 {
27 this._id = id; 27 this._id = id;
28 this._tab = tab; 28 this._tab = tab;
29 this._frames = [{url: url, parent: null}]; 29 this._frames = [{url: url, parent: null}];
30 30
31 if (tab.page) 31 if (tab.page)
32 this._messageProxy = new ext._MessageProxy(tab.page); 32 this._messageProxy = new ext._MessageProxy(tab.page);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 var obj = objects[message.objectId]; 494 var obj = objects[message.objectId];
495 var objectInfo = {properties: {}, isFunction: typeof obj == "function" }; 495 var objectInfo = {properties: {}, isFunction: typeof obj == "function" };
496 496
497 Object.getOwnPropertyNames(obj).forEach(function(prop) 497 Object.getOwnPropertyNames(obj).forEach(function(prop)
498 { 498 {
499 objectInfo.properties[prop] = { 499 objectInfo.properties[prop] = {
500 enumerable: Object.prototype.propertyIsEnumerable.call(obj, prop) 500 enumerable: Object.prototype.propertyIsEnumerable.call(obj, prop)
501 }; 501 };
502 }); 502 });
503 503
504 if (obj.__proto__) 504 var proto = Object.getPrototypeOf(obj);
505 objectInfo.prototypeId = this.registerObject(obj.__proto__, objects) ; 505 if (proto)
506 objectInfo.prototypeId = this.registerObject(proto, objects);
506 507
507 if (obj == Object.prototype) 508 if (obj == Object.prototype)
508 objectInfo.prototypeOf = "Object"; 509 objectInfo.prototypeOf = "Object";
509 if (obj == Function.prototype) 510 if (obj == Function.prototype)
510 objectInfo.prototypeOf = "Function"; 511 objectInfo.prototypeOf = "Function";
511 512
512 return objectInfo; 513 return objectInfo;
513 } 514 }
514 } 515 }
515 }; 516 };
(...skipping 14 matching lines...) Expand all
530 531
531 var pageId; 532 var pageId;
532 var frameId; 533 var frameId;
533 534
534 if (message.isTopLevel) 535 if (message.isTopLevel)
535 { 536 {
536 pageId = ++pageCounter; 537 pageId = ++pageCounter;
537 frameId = 0; 538 frameId = 0;
538 539
539 if (!('_pages' in tab)) 540 if (!('_pages' in tab))
540 tab._pages = {__proto__: null}; 541 tab._pages = Object.create(null);
541 542
542 var page = new Page(pageId, tab, message.url); 543 var page = new Page(pageId, tab, message.url);
543 pages[pageId] = tab._pages[pageId] = page; 544 pages[pageId] = tab._pages[pageId] = page;
544 545
545 // when a new page is shown, forget the previous page associated 546 // when a new page is shown, forget the previous page associated
546 // with its tab, and reset the toolbar item if necessary. 547 // with its tab, and reset the toolbar item if necessary.
547 // Note that it wouldn't be sufficient to do that when the old 548 // Note that it wouldn't be sufficient to do that when the old
548 // page is unloading, because Safari dispatches window.onunload 549 // page is unloading, because Safari dispatches window.onunload
549 // only when reloading the page or following links, but not when 550 // only when reloading the page or following links, but not when
550 // you enter a new URL in the address bar. 551 // you enter a new URL in the address bar.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 tab.activate(); 675 tab.activate();
675 if (callback) 676 if (callback)
676 callback(page); 677 callback(page);
677 return; 678 return;
678 } 679 }
679 } 680 }
680 681
681 ext.pages.open(optionsUrl, callback); 682 ext.pages.open(optionsUrl, callback);
682 }; 683 };
683 })(); 684 })();
OLDNEW
« no previous file with comments | « qunit/common.js ('k') | safari/ext/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld