Internet Explorer 11 script errors pointing to wrong file - internet-explorer-11

I struggle to find the lines of errornous code in Internet Explorer 11 as the Console is pointing to the wrong resource (pointing to HTML instead of JS code). How could I possibly find out where the actual problem can be found?
Console errors
(SCRIPT1003 is "Expected ''" and SCRIPT1028 would be "Expected identifier, string or number")
Lines of code the error refers to
Line 4 and 5:
Line 12:

Leaving this answer to my own question so others might also stumble over it with the same problem.
In case any script file is loaded asynchronously after the initial page has been loaded, the file name reported in the Console will point to the file that performed the loading of the resource. In my case I used JQuery's $.getScript() method to handle the task:
translationInitHandler.initialise(function() {
store.commit('setTranslation', window.defaultTranslationHandler.getCatalogueTranslations());
$.getScript('../src/app/report-template/warning.app.js');
$.getScript('../src/app/report-template/list.app.js');
$.getScript('../src/app/report-template/authorize.app.js');
$.getScript('../src/app/report-template/edit-configure.app.js?3');
}, false);
Funny thing is that the mentioned line and column refer to the right position in the loaded script. In my case I had (in IE11's view) an invalid property in a Vue application that had been included:
window.createApp = new Vue({
el: '#create-view',
store, // triggers IE error
data: {
...
},
...
});

Related

Problem with prestashop hook.php and tab.php files

We got an error at the top of some pages: Warning: Invalid argument supplied for foreach() in /public_html/classes/Hook.php on line 491.
I've read that it could be a problem with the foreach loop or arrays, but I don't know php and don't know how to fix it.
In line 491 I find: foreach ($results as $result) {
Another problem is that when I enter a category from the client side, I can't go to the 2nd/3rd/4th/5th page, only one page is displayed and the next ones don't want to load. The error Warning: Invalid argument supplied for foreach() in /public_html/classes/Hook.php on line 491 appears on pages that do not want to load.
I also get an error after enabling debug mode:
PrestaShopBundle\EntityTab.
The association PrestaShopBundle\EntityTab#tabLangs refers to the owning side field PrestaShopBundle\EntityTabLang#tab which does not exist.
I changed:
#ORM\OneToMany(targetEntity="PrestaShopBundle\Entity\TabLang", mappedBy="tab")
to
#ORM\OneToMany(targetEntity="PrestaShopBundle\Entity\TabLang", mappedBy="id")
insrc/PrestaShopBundle/Entity/Tab.php but it doesn't help.
PHP debug info debug info
I managed to solve the problem - I had to change active to m.active in the body of the sql query. Thank you

Selenium request returns error 400 - Bad request

I'm trying to get pull data from http://43.248.49.97/indexEn
Normally on the browser there is a first request to the url above returns error 412, the second one is to a JS file and the third one is also to the url above and returns ok (200).
When using selenium the third request returns error 400 - Bad request instead.
I'm using Python. Any ideas on why this is happening?]
Thanks
I had the same problem with you but I found a solution which perfectly solves my problem.
Maybe your program fails because you are detected as a robot using selenium.
So here is the method to solve it or hide your identity(window.navigator.webdriver) by using JavaScript:
With CDP(Chrome Devtools-Protocol), you run the code before the frame is loaded by the JS file(detector). Therefore, use these codes to remove the "webdriver True" property:
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
})
key codes:
from selenium.webdriver import Chrome
driver = Chrome('D://chromedriver.exe')
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": """
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
})
"""
})
driver.get('http://pythonlearner.com')
However, if you upgrade your Chrome to 88 right now. The method mentioned above will be useless. Fortunately, we still have a solution (add this code)
chrome_options.add_argument("--disable-blink-features=AutomationControlled")
These codes should help you pass the JS file so that you can obtain the data. At least I successfully run my program.
I am using ChromeDriver 104.0.5112.79.0 and the solution with chrome_options.add_argument("--disable-blink-features=AutomationControlled") works for me!

Not able to get file object Using YUI IN Internext Explorer

I am trying to upload a file using YUI.
Below is my code that works fine in Firefox and Chrome.But not working in IE 8.
this.portlet_view_object.delegate('change', function(e) {
......
var fileField = Y.one('#newcase_file_'+context.imageCount);
var file = fileField._node.files[0];
if(!context.maxFileSize.call(context,file)){
return;
}
....
Here, the maxFileSize, is the method to which i pass the file object and perform operation related to fiel(e.g. fileSize, fileName).
In firefox and chrome, i am getting the file object by fileField._node.files[0];
But the same thing is not working in IE 8,and getting below error.
_node.files.0' is null or not an object
Any suggestions are welcomed.
Thanks.
This issue isn't related to YUI, just to IE.
.files holds multiple selected files, but IE8 does not support this methos and can only select one file. Therefore this property isn't recognized.
You can use this workaround:
if ('files' in fileField._node)
var file = fileField._node.files[0];
else
var file = fileField._node.value;
Or skip the whole .files completely if you want to, although I personally wouldn't recommend it.

Index was outside the bounds of the array in #Scripts.Render

For each controller have a folder (with the same name controler), and for each action a script file.
For each file is creating a bundle following the pattern: "~/Scripts/Controllers/{controller-name}/{filename-without-extension}"
bundles.IncludePerFile(new DirectoryInfo(server.MapPath("~/Scripts/Controllers")), "~/Scripts/Controllers/{0}/{1}",
(dir,file) => string.Format("~/Scripts/Controllers/{0}/{1}", dir, Path.GetFileNameWithoutExtension(file)), "*.js");
IncludePerFile is an extension method I created to perform this task
Then one bundle for: ~/Scripts/Controllers/processos/pasta should exist!
And to confirm this:
So far so correct! The bundle exists!
Running app
When I run the application, the following error occurs:
Full image
Wrongly and inefficient to repair the error:
If I change this:
#Scripts.Render("~/Scripts/Controllers/processos/pasta")
to this:
#Scripts.Render("~/Scripts/Controllers/processos/pasta.js")
No error is generated. But the file is not minified since there is effectively a bundle. (I have already put in release mode and published application!)
Full error
Index was outside the bounds of the array.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.
Source Error:
Line 3: #section js {
Line 4: #*#Scripts.Render("~/Scripts/Controllers/processos/Pasta.js", "~/Scripts/Controllers/processos/display.js")*#
Line 5: #Scripts.Render("~/Scripts/Controllers/processos/pasta")
Line 6: #Scripts.Render("~/Scripts/Controllers/processos/display.js")
Line 7:
Source File: w:\Clients\creditoimobiliariobb\sistema\src\CreditoImobiliarioBB\CreditoImobiliarioBB.Web\Views\processos\display.cshtml Line: 5
Stack Trace:
[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.String.get_Chars(Int32 index) +0
Microsoft.Ajax.Utilities.CssParser.Append(Object obj, TokenType tokenType) +402
Microsoft.Ajax.Utilities.CssParser.AppendCurrent() +74
Microsoft.Ajax.Utilities.CssParser.SkipToClose() +744
Microsoft.Ajax.Utilities.CssParser.SkipToEndOfStatement() +232
Microsoft.Ajax.Utilities.CssParser.ParseRule() +574
Microsoft.Ajax.Utilities.CssParser.ParseStylesheet() +1235
Microsoft.Ajax.Utilities.CssParser.Parse(String source) +897
Microsoft.Ajax.Utilities.Minifier.MinifyStyleSheet(String source, CssSettings settings) +419
System.Web.Optimization.CssMinify.Process(BundleContext context, BundleResponse response) +302
System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable`1 bundleFiles) +207
System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context) +355
System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) +104
System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath) +254
System.Web.Optimization.AssetManager.EliminateDuplicatesAndResolveUrls(IEnumerable`1 refs) +435
System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets) +1029
System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) +75
System.Web.Optimization.Scripts.RenderFormat(String tagFormat, String[] paths) +292
System.Web.Optimization.Scripts.Render(String[] paths) +51
I've had the same error in this question: StyleBundle Index was outside the bounds of the array
And answer is pretty simple: you have to update your Microsoft Web Optimization & WebGrease packages (at this time 1.1.2 & 1.6.0 versions)
I would verify that all the elements of your
IncludePerFile(new DirectoryInfo(server.MapPath("~/Scripts/Controllers")), "~/Scripts/Controllers/{0}/{1}",
(dir,file) => string.Format("~/Scripts/Controllers/{0}/{1}", dir, Path.GetFileNameWithoutExtension(file)), "*.js")
are putting in the created bundles exactly what you think they're putting in.
I got this error at run time when the wrong type of file is included within a bundle. i.e.
#Styles.Render("~/bundles/myStyleBundle");
actually contains a JavaScript file.
I had the same problem and when I tried different checking I found out that there is a selector in my css file like this that cause the problem:
.glyphicons-icon _:-o-prefocus,
.glyphicons-icon {
background-image: url(../images/glyphicons.png);
}
it seems that Microsoft.Ajax.Utilities.CssParser has a problem with _: css selector. I removed the line and it's working.
I just ran into a similar problem. I am using VS 2013 and MVC 5 and was updating to Bootstrap v3.0.1 in order to use a theme from Bootswatch. I updated everything using the latest Bootstrap download and the site seemed to work fine. I then grabbed the CSS for Slate from the Bootswatch site and used it in the new stylesheet, changed it in the StyleBundle and built solution. When I ran it, I got the "Index was outside the bounds of the array" error. Switch back to bootstrap.css and it worked fine.
I then used NuGet Package Manager to update all my packages... I had just installed VS 2013 and not yet updated everything. Rebuilt the solution and wallah, it works great. So I would up vote the updating your packages answser.
You may need to update some of your nuget libraries. Try updating WebGrease
I'm using
#Scripts.Render()
For me it was an issue with the backtik in JS file.
Sample 1
let something = `some text
bla bla
`;
Above code thrown this exception
Index and length must refer to a location within the string.
Sample 2
let something = `some text
bla bla`;
Now it works well, so do not keep the closing backtik at the beginning new line ...

Testing Backbone Model with Jasmine and Sinon - Object #<Object> has no method 'spy'

I am trying to learn how to use Jasmine and Sinon for testing a Backbone application, and I was following this tutorial. Nevertheless, I ran into a problem that I don't know how to solve.
Most likely the solution is simple, but I need some guidance ...
In my project.spec.js file this is the code that is giving the problem:
it("should not save when name is empty", function() {
var eventSpy = sinon.spy();
this.project.bind("error", eventSpy);
this.project.save({"name": ""});
expect(this.eventSpy.calledOnce).toBeTruthy();
expect(this.eventSpy.calledWith(
this.project,
"cannot have an empty name"
)).toBeTruthy();
});
And this is the specific error that can be seen in the browser:
Failing 1 spec
7 specs | 1 failing
Project model should not save when name is empty.
TypeError: Object #<Object> has no method 'spy'
TypeError: Object #<Object> has no method 'spy'
at null.<anonymous> (http://localhost:8888/__spec__/models/project.spec.js:53:26)
at jasmine.Block.execute (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:1024:15)
at jasmine.Queue.next_ (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2025:31)
at jasmine.Queue.start (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:1978:8)
at jasmine.Spec.execute (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2305:14)
at jasmine.Queue.next_ (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2025:31)
at onComplete (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2021:18)
at jasmine.Suite.finish (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2407:5)
at null.onComplete (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2451:10)
at jasmine.Queue.next_ (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2035:14)
In addition to the sinon.js library, I have installed the jasmine-sinon.js library (both are in the vendor/assets/javascripts folder and are included in the application.js file).
Thank you,
Alexandra
I faced this problem when I downloaded sinon.js file from GitHub (without Sinon folder). I solved the problem by downloading the library from http://sinonjs.org/
I'm going to post this as an answer, based on the comment thread above. We've narrowed down the problem to the line where sinon.spy() is called, so it's not specific to this test but to how sinon is being loaded.
I suspect the problem is that you're including sinon and jasmine-sinon in application.js, when they should really go in spec/javascripts/spec.js (in the same format). Try changing that and see if anything changes.
UPDATE:
Based on the comment thread below, it seems the code is getting to the this.project.save(...) line but the validations aren't working: I know this because if you're getting a POST error in the console, it means that backbone actually made the request (which it should not have because the name is empty). So you should go back and check the code you are actually testing.
I know this thread is old, but I had a similar issue today with this when going through this tutorial http://tinnedfruit.com/2011/03/25/testing-backbone-apps-with-jasmine-sinon-2.html. It looks like Backbone made a change and it calls the 'invalid' event when invalid model data is provided, not 'error'.
If you run into this error try changing:
it("should not save when name is empty", function() {
...
this.project.bind("error", eventSpy);
...
});
To:
it("should not save when name is empty", function() {
...
this.project.bind("invalid", eventSpy);
...
});
This resolved the issue for me.