From 3a83266acee37e99832adaf1337c6b3ab7559f50 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 2 Mar 2015 12:59:05 -0800 Subject: Merge to XFA: Return error information from pdfium to JS. Cherry-pick from b720d0a14601f1496ef15297bc46d401f5a2a890 + Manually resolve merge conflicts + Fix more IWYU to fix compile. Original Review URL: https://codereview.chromium.org/963193003 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/971013002 --- testing/resources/javascript/document_props.in | 30 +++++++-------- .../javascript/document_props_expected.txt | 12 +++--- testing/resources/javascript/globals.in | 44 ++++++++++++++++------ testing/resources/javascript/globals_expected.txt | 10 +++++ 4 files changed, 64 insertions(+), 32 deletions(-) (limited to 'testing') diff --git a/testing/resources/javascript/document_props.in b/testing/resources/javascript/document_props.in index 8ab7e3d566..c628fafad2 100644 --- a/testing/resources/javascript/document_props.in +++ b/testing/resources/javascript/document_props.in @@ -105,27 +105,27 @@ var document_props = [ ]; function testGetProps(props) { - try { - app.alert('*** Getting properties ***'); - for (var i = 0; i < props.length; ++i) { - var expr1 = "this." + props[i]; - var expr2 = "typeof " + expr1; - app.alert(expr1 + " is " + eval(expr2) + ' ' + eval(expr1)); + app.alert('*** Getting properties ***'); + for (var i = 0; i < props.length; ++i) { + try { + var expr1 = "this." + props[i]; + var expr2 = "typeof " + expr1; + app.alert(expr1 + " is " + eval(expr2) + ' ' + eval(expr1)); + } catch (e) { + app.alert("ERROR: " + e.toString()); } - } catch (e) { - app.alert("ERROR: " + e.toString()); } } function testSetProps(props) { - try { - app.alert('*** Setting properties ***'); - for (var i = 0; i < props.length; ++i) { - var expr1 = "this." + props[i] + ' = 3;' - app.alert(expr1 + " yields " + eval(expr1)); + app.alert('*** Setting properties ***'); + for (var i = 0; i < props.length; ++i) { + try { + var expr1 = "this." + props[i] + ' = 3;' + app.alert(expr1 + " yields " + eval(expr1)); + } catch (e) { + app.alert("ERROR: " + e.toString()); } - } catch (e) { - app.alert("ERROR: " + e.toString()); } } diff --git a/testing/resources/javascript/document_props_expected.txt b/testing/resources/javascript/document_props_expected.txt index 38bea97acb..728d2455e1 100644 --- a/testing/resources/javascript/document_props_expected.txt +++ b/testing/resources/javascript/document_props_expected.txt @@ -41,10 +41,10 @@ Alert: this.creationDate = 3; yields 3 Alert: this.creator = 3; yields 3 Alert: this.delay = 3; yields 3 Alert: this.dirty = 3; yields 3 -Alert: this.documentFileName = 3; yields 3 +Alert: ERROR: Document.documentFileName: Cannot assign to readonly property. Alert: this.external = 3; yields 3 -Alert: this.filesize = 3; yields 3 -Alert: this.icons = 3; yields 3 +Alert: ERROR: Document.filesize: Cannot assign to readonly property. +Alert: ERROR: Document.icons: Cannot assign to readonly property. Alert: this.info = 3; yields 3 Alert: this.keywords = 3; yields 3 Alert: this.layout = 3; yields 3 @@ -52,12 +52,12 @@ Alert: this.media = 3; yields 3 Alert: this.modDate = 3; yields 3 Alert: this.mouseX = 3; yields 3 Alert: this.mouseY = 3; yields 3 -Alert: this.numFields = 3; yields 3 -Alert: this.numPages = 3; yields 3 +Alert: ERROR: Document.numFields: Cannot assign to readonly property. +Alert: ERROR: Document.numPages: Cannot assign to readonly property. Goto Page: 3 Alert: this.pageNum = 3; yields 3 Alert: this.pageWindowRect = 3; yields 3 -Alert: this.path = 3; yields 3 +Alert: ERROR: Document.path: Cannot assign to readonly property. Alert: this.producer = 3; yields 3 Alert: this.subject = 3; yields 3 Alert: this.title = 3; yields 3 diff --git a/testing/resources/javascript/globals.in b/testing/resources/javascript/globals.in index 6d2f3ca241..4812101e7a 100644 --- a/testing/resources/javascript/globals.in +++ b/testing/resources/javascript/globals.in @@ -63,21 +63,34 @@ var props_to_test = [ function setup_global() { for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - global[prop.name] = prop.value; + try { + global[prop.name] = prop.value; + } catch (e) { + app.alert("For " + prop.name + ": Setup: ERROR: " + e.toString()); + } } } function delete_global() { for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - delete global[prop.name]; + try { + delete global[prop.name]; + } catch (e) { + app.alert("For " + prop.name + ": Delete: ERROR: " + e.toString()); + } } } function persist_global(should_persist) { for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - global.setPersistent(prop.name, should_persist); + try { + global.setPersistent(prop.name, should_persist); + } catch (e) { + app.alert("For " + prop.name + + ": Set Persistent: ERROR: " + e.toString()); + } } } @@ -85,18 +98,27 @@ function dump_global(msg) { app.alert("************ " + msg + " ************"); app.alert("Enumerable Globals:"); for (var name in global) { - app.alert(" " + name + " = " + global[name] + - ", own property = " + global.hasOwnProperty(name)); + try { + app.alert(" " + name + " = " + global[name] + + ", own property = " + global.hasOwnProperty(name)); + } catch (e) { + app.alert("For " + name + ": Dump: ERROR: " + e.toString()); + } } app.alert("Expected Globals:"); for (var i = 0; i < props_to_test.length; ++i) { var prop = props_to_test[i]; - var actual = global[prop.name]; - app.alert(" " + prop.name + " = " + actual); - if (actual != null && typeof actual == "object") { - app.alert(" " + actual.colors[0]); - app.alert(" " + actual.colors[1]); - app.alert(" " + actual.colors[2]); + try { + var actual = global[prop.name]; + app.alert(" " + prop.name + " = " + actual); + if (actual != null && typeof actual == "object") { + app.alert(" " + actual.colors[0]); + app.alert(" " + actual.colors[1]); + app.alert(" " + actual.colors[2]); + } + } catch (e) { + app.alert("For " + prop.name + + ": Dump Expected: ERROR: " + e.toString()); } } } diff --git a/testing/resources/javascript/globals_expected.txt b/testing/resources/javascript/globals_expected.txt index ddaa00cd09..fcebd70466 100644 --- a/testing/resources/javascript/globals_expected.txt +++ b/testing/resources/javascript/globals_expected.txt @@ -45,6 +45,7 @@ Alert: string_var = undefined Alert: object_var = undefined Alert: null_var = undefined Alert: undefined_var = undefined +Alert: For undefined_var: Set Persistent: ERROR: global.setPersistent: Global value not found. Alert: ************ After Setup and Persist false ************ Alert: Enumerable Globals: Alert: setPersistent = function setPersistent() { [native code] }, own property = true @@ -68,6 +69,14 @@ Alert: green Alert: blue Alert: null_var = null Alert: undefined_var = undefined +Alert: For true_var: Set Persistent: ERROR: global.setPersistent: Global value not found. +Alert: For false_var: Set Persistent: ERROR: global.setPersistent: Global value not found. +Alert: For zero_var: Set Persistent: ERROR: global.setPersistent: Global value not found. +Alert: For number_var: Set Persistent: ERROR: global.setPersistent: Global value not found. +Alert: For string_var: Set Persistent: ERROR: global.setPersistent: Global value not found. +Alert: For object_var: Set Persistent: ERROR: global.setPersistent: Global value not found. +Alert: For null_var: Set Persistent: ERROR: global.setPersistent: Global value not found. +Alert: For undefined_var: Set Persistent: ERROR: global.setPersistent: Global value not found. Alert: ************ After Delete and Persist ************ Alert: Enumerable Globals: Alert: setPersistent = function setPersistent() { [native code] }, own property = true @@ -80,6 +89,7 @@ Alert: string_var = undefined Alert: object_var = undefined Alert: null_var = undefined Alert: undefined_var = undefined +Alert: For undefined_var: Set Persistent: ERROR: global.setPersistent: Global value not found. Alert: ************ After Setup and Persist true ************ Alert: Enumerable Globals: Alert: setPersistent = function setPersistent() { [native code] }, own property = true -- cgit v1.2.3