Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm version diff #120

Closed
logrithumn opened this issue May 28, 2018 · 1 comment
Closed

npm version diff #120

logrithumn opened this issue May 28, 2018 · 1 comment

Comments

@logrithumn
Copy link

logrithumn commented May 28, 2018

Hello, there is a difference between npm and git, please update.

npm

content-script

browser.runtime.sendMessage(object).then((request, err) => {console.log(request)});

background

browser.runtime.onMessage.addListener((request, sender, send_response) => {
  ...
  send_response({status : 200});
  return true;
});

always return true in chrome.

git

Everything works fine

{
  status : 200
}
diff
  extension\dist\js\browser-polyfill.js -> npm
  src\modules_js\browser-polyfill.js    -> git
λ diff extension\dist\js\browser-polyfill.js src\modules_js\browser-polyfill.js                                                                                            
14c14                                                                                                                                                                      
<   /* webextension-polyfill - v0.2.1 - Thu Oct 12 2017 12:31:04 */                                                                                                        
---                                                                                                                                                                        
>   /* webextension-polyfill - v0.2.1 - Mon May 28 2018 12:29:17 */                                                                                                        
271a272,277                                                                                                                                                                
>         "identity": {                                                                                                                                                    
>           "launchWebAuthFlow": {                                                                                                                                         
>             "minArgs": 1,                                                                                                                                                
>             "maxArgs": 1                                                                                                                                                 
>           }                                                                                                                                                              
>         },                                                                                                                                                               
322a329,333                                                                                                                                                                
>           "setPopup": {                                                                                                                                                  
>             "minArgs": 1,                                                                                                                                                
>             "maxArgs": 1,                                                                                                                                                
>             "fallbackToNoCallback": true                                                                                                                                 
>           },                                                                                                                                                             
326a338,342                                                                                                                                                                
>           "setTitle": {                                                                                                                                                  
>             "minArgs": 1,                                                                                                                                                
>             "maxArgs": 1,                                                                                                                                                
>             "fallbackToNoCallback": true                                                                                                                                 
>           },                                                                                                                                                             
328,329c344,346                                                                                                                                                            
<             "minArgs": 0,                                                                                                                                                
<             "maxArgs": 0                                                                                                                                                 
---                                                                                                                                                                        
>             "minArgs": 1,                                                                                                                                                
>             "maxArgs": 1,                                                                                                                                                
>             "fallbackToNoCallback": true                                                                                                                                 
334a352,355                                                                                                                                                                
>           "getIcon": {                                                                                                                                                   
>             "minArgs": 1,                                                                                                                                                
>             "maxArgs": 1                                                                                                                                                 
>           },                                                                                                                                                             
336,337c357,359                                                                                                                                                            
<             "minArgs": 0,                                                                                                                                                
<             "maxArgs": 0                                                                                                                                                 
---                                                                                                                                                                        
>             "minArgs": 1,                                                                                                                                                
>             "maxArgs": 1,                                                                                                                                                
>             "fallbackToNoCallback": true                                                                                                                                 
674c696,719                                                                                                                                                                
<             target[name](...args, makeCallback({ resolve, reject }, metadata));                                                                                          
---                                                                                                                                                                        
>             if (metadata.fallbackToNoCallback) {                                                                                                                         
>               // This API method has currently no callback on Chrome, but it return a promise on Firefox,                                                                
>               // and so the polyfill will try to call it with a callback first, and it will fallback                                                                     
>               // to not passing the callback if the first call fails.                                                                                                    
>               try {                                                                                                                                                      
>                 target[name](...args, makeCallback({ resolve, reject }, metadata));                                                                                      
>               } catch (cbError) {                                                                                                                                        
>                 console.warn(`${name} API method doesn't seem to support the callback parameter, ` + "falling back to call it without a callback: ", cbError);           
>                                                                                                                                                                          
>                 target[name](...args);                                                                                                                                   
>                                                                                                                                                                          
>                 // Update the API method metadata, so that the next API calls will not try to                                                                            
>                 // use the unsupported callback anymore.                                                                                                                 
>                 metadata.fallbackToNoCallback = false;                                                                                                                   
>                 metadata.noCallback = true;                                                                                                                              
>                                                                                                                                                                          
>                 resolve();                                                                                                                                               
>               }                                                                                                                                                          
>             } else if (metadata.noCallback) {                                                                                                                            
>               target[name](...args);                                                                                                                                     
>               resolve();                                                                                                                                                 
>             } else {                                                                                                                                                     
>               target[name](...args, makeCallback({ resolve, reject }, metadata));                                                                                        
>             }                                                                                                                                                            
733d777                                                                                                                                                                    
<                                                                                                                                                                          
735c779                                                                                                                                                                    
<           has(target, prop) {                                                                                                                                            
---                                                                                                                                                                        
>           has(proxyTarget, prop) {                                                                                                                                       
739c783                                                                                                                                                                    
<           get(target, prop, receiver) {                                                                                                                                  
---                                                                                                                                                                        
>           get(proxyTarget, prop, receiver) {                                                                                                                             
793c837                                                                                                                                                                    
<           set(target, prop, value, receiver) {                                                                                                                           
---                                                                                                                                                                        
>           set(proxyTarget, prop, value, receiver) {                                                                                                                      
802c846                                                                                                                                                                    
<           defineProperty(target, prop, desc) {                                                                                                                           
---                                                                                                                                                                        
>           defineProperty(proxyTarget, prop, desc) {                                                                                                                      
806c850                                                                                                                                                                    
<           deleteProperty(target, prop) {                                                                                                                                 
---                                                                                                                                                                        
>           deleteProperty(proxyTarget, prop) {                                                                                                                            
811c855,866                                                                                                                                                                
<         return new Proxy(target, handlers);                                                                                                                              
---                                                                                                                                                                        
>         // Per contract of the Proxy API, the "get" proxy handler must return the                                                                                        
>         // original value of the target if that value is declared read-only and                                                                                          
>         // non-configurable. For this reason, we create an object with the                                                                                               
>         // prototype set to `target` instead of using `target` directly.                                                                                                 
>         // Otherwise we cannot return a custom object for APIs that                                                                                                      
>         // are declared read-only and non-configurable, such as `chrome.devtools`.                                                                                       
>         //                                                                                                                                                               
>         // The proxy handlers themselves will still use the original `target`                                                                                            
>         // instead of the `proxyTarget`, so that the methods and properties are                                                                                          
>         // dereferenced via the original targets.                                                                                                                        
>         let proxyTarget = Object.create(target);                                                                                                                         
>         return new Proxy(proxyTarget, handlers);                                                                                                                         
867c922                                                                                                                                                                    
<           let result = listener(message, sender);                                                                                                                        
---                                                                                                                                                                        
>           let didCallSendResponse = false;                                                                                                                               
869c924,946                                                                                                                                                                
<           if (isThenable(result)) {                                                                                                                                      
---                                                                                                                                                                        
>           let wrappedSendResponse;                                                                                                                                       
>           let sendResponsePromise = new Promise(resolve => {                                                                                                             
>             wrappedSendResponse = function (response) {                                                                                                                  
>               didCallSendResponse = true;                                                                                                                                
>               resolve(response);                                                                                                                                         
>             };                                                                                                                                                           
>           });                                                                                                                                                            
>                                                                                                                                                                          
>           let result = listener(message, sender, wrappedSendResponse);                                                                                                   
>                                                                                                                                                                          
>           const isResultThenable = result !== true && isThenable(result);                                                                                                
>                                                                                                                                                                          
>           // If the listener didn't returned true or a Promise, or called                                                                                                
>           // wrappedSendResponse synchronously, we can exit earlier                                                                                                      
>           // because there will be no response sent from this listener.                                                                                                  
>           if (result !== true && !isResultThenable && !didCallSendResponse) {                                                                                            
>             return false;                                                                                                                                                
>           }                                                                                                                                                              
>                                                                                                                                                                          
>           // If the listener returned a Promise, send the resolved value as a                                                                                            
>           // result, otherwise wait the promise related to the wrappedSendResponse                                                                                       
>           // callback to resolve and send it as a response.                                                                                                              
>           if (isResultThenable) {                                                                                                                                        
872c949,961                                                                                                                                                                
<               sendResponse(error);                                                                                                                                       
---                                                                                                                                                                        
>               // TODO: the error object is not serializable and so for now we just send                                                                                  
>               // `undefined`. Nevertheless, as being discussed in #97, this is not yet                                                                                   
>               // providing the expected behavior (the promise received from the sender should                                                                            
>               // be rejected when the promise returned by the listener is being rejected).                                                                               
>               sendResponse(undefined);                                                                                                                                   
>             });                                                                                                                                                          
>           } else {                                                                                                                                                       
>             sendResponsePromise.then(sendResponse, error => {                                                                                                            
>               console.error(error);                                                                                                                                      
>               // TODO: same as above, we are currently sending `undefined` in this scenario                                                                              
>               // because the error oject is not serializable, but it is not yet the behavior                                                                             
>               // that this scenario should present.                                                                                                                      
>               sendResponse(undefined);                                                                                                                                   
874,877d962                                                                                                                                                                
<                                                                                                                                                                          
<             return true;                                                                                                                                                 
<           } else if (result !== undefined) {                                                                                                                             
<             sendResponse(result);                                                                                                                                        
878a964,966                                                                                                                                                                
>                                                                                                                                                                          
>           // Let Chrome know that the listener is replying.                                                                                                              
>           return true;                                                                                                                                                   
888,893c976                                                                                                                                                                
<       // Create a new empty object and copy the properties of the original chrome object                                                                                 
<       // to prevent a Proxy violation exception for the devtools API getter                                                                                              
<       // (which is a read-only non-configurable property on the original target).                                                                                        
<       const targetObject = Object.assign({}, chrome);                                                                                                                    
<                                                                                                                                                                          
<       return wrapObject(targetObject, staticWrappers, apiMetadata);                                                                                                      
---                                                                                                                                                                        
>       return wrapObject(chrome, staticWrappers, apiMetadata);                                                                                                            
                                                                                                                                                                           

@Rob--W
Copy link
Member

Rob--W commented Jul 5, 2018

This will be fixed when we release a new version. Keep an eye on #88.

@Rob--W Rob--W closed this as completed Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants