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

Side by Side Diff: blockElement.postload.js

Issue 29336576: Issue 2426 - Ensure the top frame gets blockelementPopupId (Closed)
Patch Set: Created Feb. 18, 2016, 9:12 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 | « no previous file | no next file » | 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 let element = currentElement.prisoner || currentElement; 380 let element = currentElement.prisoner || currentElement;
381 getFiltersForElement(element, (filters, selectors) => 381 getFiltersForElement(element, (filters, selectors) =>
382 { 382 {
383 if (currentlyPickingElement) 383 if (currentlyPickingElement)
384 stopPickingElement(); 384 stopPickingElement();
385 385
386 ext.backgroundPage.sendMessage( 386 ext.backgroundPage.sendMessage(
387 { 387 {
388 type: "blockelement-open-popup" 388 type: "blockelement-open-popup"
389 }, 389 },
390 response => 390 popupId =>
391 { 391 {
392 blockelementPopupId = response;
393 ext.backgroundPage.sendMessage( 392 ext.backgroundPage.sendMessage(
394 { 393 {
395 type: "forward", 394 type: "forward",
396 targetPageId: blockelementPopupId, 395 targetPageId: popupId,
397 payload: 396 payload:
398 { 397 {
399 type: "blockelement-popup-init", 398 type: "blockelement-popup-init",
400 filters: filters 399 filters: filters
401 } 400 }
402 }); 401 });
402
403 // Only the top frame keeps a record of the popup window's ID,
404 // so if this isn't the top frame we need to pass the ID on.
405 if (window == window.top)
406 {
407 blockelementPopupId = popupId;
408 }
409 else
410 {
411 ext.backgroundPage.sendMessage(
412 {
413 type: "forward",
414 payload:
415 {
416 type: "blockelement-popup-opened",
417 popupId: popupId
418 }
419 });
420 }
403 }); 421 });
404 422
405 if (selectors.length > 0) 423 if (selectors.length > 0)
406 highlightElements(selectors.join(",")); 424 highlightElements(selectors.join(","));
407 425
408 highlightElement(currentElement, "#fd1708", "#f6a1b5"); 426 highlightElement(currentElement, "#fd1708", "#f6a1b5");
409 }); 427 });
410 428
411 event.preventDefault(); 429 event.preventDefault();
412 event.stopPropagation(); 430 event.stopPropagation();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // Apply added element hiding filters. 555 // Apply added element hiding filters.
538 updateStylesheet(); 556 updateStylesheet();
539 } 557 }
540 deactivateBlockElement(); 558 deactivateBlockElement();
541 break; 559 break;
542 case "blockelement-clear-previous-right-click-event": 560 case "blockelement-clear-previous-right-click-event":
543 if (!lastRightClickEventIsMostRecent) 561 if (!lastRightClickEventIsMostRecent)
544 lastRightClickEvent = null; 562 lastRightClickEvent = null;
545 lastRightClickEventIsMostRecent = false; 563 lastRightClickEventIsMostRecent = false;
546 break; 564 break;
565 case "blockelement-popup-opened":
566 if (window == window.top)
567 blockelementPopupId = msg.popupId;
568 break;
547 case "blockelement-popup-closed": 569 case "blockelement-popup-closed":
548 // The onRemoved hook for the popup can create a race condition, so we 570 // The onRemoved hook for the popup can create a race condition, so we
549 // to be careful here. (This is not perfect, but best we can do.) 571 // to be careful here. (This is not perfect, but best we can do.)
550 if (window == window.top && blockelementPopupId == msg.popupId) 572 if (window == window.top && blockelementPopupId == msg.popupId)
551 { 573 {
552 ext.backgroundPage.sendMessage( 574 ext.backgroundPage.sendMessage(
553 { 575 {
554 type: "forward", 576 type: "forward",
555 payload: 577 payload:
556 { 578 {
557 type: "blockelement-finished" 579 type: "blockelement-finished"
558 } 580 }
559 }); 581 });
560 } 582 }
561 break; 583 break;
562 } 584 }
563 }); 585 });
564 586
565 if (window == window.top) 587 if (window == window.top)
566 ext.backgroundPage.sendMessage({type: "report-html-page"}); 588 ext.backgroundPage.sendMessage({type: "report-html-page"});
567 } 589 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld