24 /MediaBox [0 0 612 792]
33 % JS program to exexute
37 // The "global" object stores data in a C-like manner, and
38 // can theoretically persist them between sessions (though
39 // pdfium deliberately excludes that functionality).
41 var some_object = { "colors": [ "red", "green", "blue"] };
44 // Cover both bool values.
45 { "name": "true_var", "value": true },
46 { "name": "false_var", "value": false },
48 // Include both zero and a number with some fractional digits.
49 { "name": "zero_var", "value": 0 },
50 { "name": "number_var", "value": -3.918 },
52 // TODO(tsepez): unicode doesn't seem to survive.
53 { "name": "string_var", "value": "This is a string" },
55 // Try a complex object.
56 { "name": "object_var", "value": some_object },
58 // Test null and undefined.
59 { "name": "null_var", "value": null },
60 { "name": "undefined_var", "value": undefined }
63 function setup_global() {
64 for (var i = 0; i < props_to_test.length; ++i) {
65 var prop = props_to_test[i];
66 global[prop.name] = prop.value;
70 function delete_global() {
71 for (var i = 0; i < props_to_test.length; ++i) {
72 var prop = props_to_test[i];
73 delete global[prop.name];
77 function persist_global(should_persist) {
78 for (var i = 0; i < props_to_test.length; ++i) {
79 var prop = props_to_test[i];
80 global.setPersistent(prop.name, should_persist);
84 function dump_global(msg) {
85 app.alert("************ " + msg + " ************");
86 app.alert("Enumerable Globals:");
87 for (var name in global) {
88 app.alert(" " + name + " = " + global[name] +
89 ", own property = " + global.hasOwnProperty(name));
91 app.alert("Expected Globals:");
92 for (var i = 0; i < props_to_test.length; ++i) {
93 var prop = props_to_test[i];
94 var actual = global[prop.name];
95 app.alert(" " + prop.name + " = " + actual);
96 if (actual != null && typeof actual == "object") {
97 app.alert(" " + actual.colors[0]);
98 app.alert(" " + actual.colors[1]);
99 app.alert(" " + actual.colors[2]);
104 dump_global("Initial State");
106 // Check that they all exist.
108 dump_global("After Setup");
112 dump_global("After Deletion");
114 // setPersistent() should be a no-op for pdfium.
116 persist_global(false);
117 dump_global("After Setup and Persist false");
119 // Test setting deleted variables as persistent.
121 persist_global(true);
122 dump_global("After Delete and Persist");
124 // Exit with variables marked as persistent to test whatever path
125 // may exist to persist them (should be igonored on pdfium).
127 persist_global(true);
128 dump_global("After Setup and Persist true");