| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 | 558 |
| 559 if (!frames) | 559 if (!frames) |
| 560 return null; | 560 return null; |
| 561 | 561 |
| 562 let frame; | 562 let frame; |
| 563 // In Microsoft Edge (version 42.17134.1.0) we don't have frameId | 563 // In Microsoft Edge (version 42.17134.1.0) we don't have frameId |
| 564 // so we fall back to iterating over the tab's frames | 564 // so we fall back to iterating over the tab's frames |
| 565 // see https://developer.microsoft.com/en-us/microsoft-edge/platform/i ssues/11716733 | 565 // see https://developer.microsoft.com/en-us/microsoft-edge/platform/i ssues/11716733 |
| 566 if (rawSender.frameId != undefined) | 566 if (rawSender.frameId != undefined) |
| 567 frame = frames.get(rawSender.frameId); | 567 frame = frames.get(rawSender.frameId); |
| 568 else | 568 else if (rawSender.url) |
| 569 { | 569 { |
| 570 for (let [key, value] of frames) | 570 let rawSenderHref = rawSender.url.replace(/#.*/, ""); |
|
kzar
2018/07/17 16:54:35
Nit: Would be nice to use some more descriptive va
geo
2018/07/18 16:08:11
Done.
| |
| 571 | |
| 572 for (let [frameId, frameInfo] of frames) | |
| 571 { | 573 { |
| 572 let valueHref = value.url.href.replace(/#.*/, ""); | 574 let frameInfoHref = frameInfo.url.href.replace(/#.*/, ""); |
|
kzar
2018/07/17 16:54:35
Nit: I'd consider using `String.prototype.substrin
geo
2018/07/18 16:08:10
I'm not sure either, but for `String.prototype.sub
| |
| 573 | 575 |
| 574 let rawSenderHref = rawSender.url ? | 576 // If we have two frames with the same URL |
|
kzar
2018/07/17 16:54:35
Can't we do this outside of the for loop?
geo
2018/07/18 16:08:10
Done.
| |
| 575 rawSender.url.replace(/#.*/, "") : | |
| 576 ""; | |
| 577 | |
| 578 // if we have two frames with the same URL | |
|
kzar
2018/07/17 16:54:35
Nit: This is a good comment, but would you mind ca
geo
2018/07/18 16:08:10
Done.
| |
| 579 // we are going to pick the first one we find | 577 // we are going to pick the first one we find |
| 580 // as we have no other way of distinguishing between them | 578 // as we have no other way of distinguishing between them. |
| 581 if (valueHref == rawSenderHref) | 579 if (frameInfoHref == rawSenderHref) |
| 582 { | 580 { |
| 583 frame = value; | 581 frame = frameInfo; |
| 584 this.id = key; | 582 this.id = frameId; |
| 585 break; | 583 break; |
| 586 } | 584 } |
| 587 } | 585 } |
| 588 } | 586 } |
| 589 | 587 |
| 590 if (frame) | 588 if (frame) |
| 591 return frame.parent || null; | 589 return frame.parent || null; |
| 592 return frames.get(0) || null; | 590 return frames.get(0) || null; |
| 593 } | 591 } |
| 594 }; | 592 }; |
| 595 } | 593 } |
| 596 | 594 |
| 597 return ext.onMessage._dispatch( | 595 return ext.onMessage._dispatch( |
| 598 message, sender, sendResponse | 596 message, sender, sendResponse |
| 599 ).includes(true); | 597 ).includes(true); |
| 600 }); | 598 }); |
| 601 } | 599 } |
| LEFT | RIGHT |